Hisashi Posted June 15, 2021 Posted June 15, 2021 (edited) Hello, I want to make blocks appear only on the homepage, not within articles Just as it happens in forums, it doesn't appear inside topics unless you put Edited June 16, 2021 by Hisashi
opentype Posted June 15, 2021 Posted June 15, 2021 (edited) All views of a database page have the same blocks, unless the visibility is coded into the block itself. For a homepage, it can make sense not to use the article database itself but to create a new page and then put the article feed on there as a block. This gives more freedom regarding the blocks. I do that on one of my sites. This is the homepage with an article listing (as blocks) plus sidebar widgets. The actual article page is here without a sidebar. So it gives the result you ask for (in a way). Edited June 15, 2021 by opentype
Hisashi Posted June 15, 2021 Author Posted June 15, 2021 (edited) 1 hour ago, opentype said: All views of a database page have the same blocks, unless the visibility is coded into the block itself. For a homepage, it can make sense not to use the article database itself but to create a new page and then put the article feed on there as a block. This gives more freedom regarding the blocks. I do that on one of my sites. This is the homepage with an article listing (as blocks) plus sidebar widgets. The actual article page is here without a sidebar. So it gives the result you ask for (in a way). That's exactly what I want to do, I just don't understand how to do it hahah --- Thus, article without a block on sidebar Edited June 15, 2021 by Hisashi
Hisashi Posted June 15, 2021 Author Posted June 15, 2021 (edited) Just for information, I'm using simple cms settings Page builder With a database Now I just need the blocks I put on sidebar don't appear inside articles Edited June 15, 2021 by Hisashi
Nathan Explosion Posted June 15, 2021 Posted June 15, 2021 3 minutes ago, Hisashi said: the blocks What blocks exactly? Custom ones you have made yourself, or the default ones provided by the software?
Hisashi Posted June 15, 2021 Author Posted June 15, 2021 (edited) 24 minutes ago, Nathan Explosion said: What blocks exactly? Custom ones you have made yourself, or the default ones provided by the software? I don't speak fluent english so sorry if you're confused. I want to make it not appear within post Staying this way, only appearing on homepage where I put Edited June 15, 2021 by Hisashi
Solution Nathan Explosion Posted June 15, 2021 Solution Posted June 15, 2021 32 minutes ago, Hisashi said: so sorry if you're confused. I'm not confused - I'm clarifying your request to move from the general ("the blocks") to the specific ("the Recent Status Update block"), and your response confirms that it is the default blocks that you are asking about. The 'fix' is to use custom blocks instead, as follows (note: I am not providing what you put in to every field, I am providing the specific things that need to be done...the rest is up to you) ACP Pages -> Blocks -> Create Block In the second field ('Plugin') select the block you want to use ('Recent Status Updates') Give it a name (example: myBlock) Save this Pages -> Blocks -> Create Block This time, choose 'Custom' -> 'Manual HTML' On the first tab, name your custom block On the 'Content' tab, insert the code below On the same tab, DO NOT enable 'Cache this block' Save the new custom block Now, on the front-end you put that custom block in place, instead of the 'Recent Status Updates' block {{if \IPS\Request::i()->controller==='page' AND !isset(\IPS\Request::i()->id)}} {block="myBlock"} {{endif}} Why do it this way? The 'Recent Status Updates' block is cached, so adding the {{if....}} statement in its content will end up with strange caching results. Result (there may be some finesse needed, but there is your starting point): abobader, SeNioR- and Hisashi 2 1
Hisashi Posted June 15, 2021 Author Posted June 15, 2021 39 minutes ago, Nathan Explosion said: I'm not confused - I'm clarifying your request to move from the general ("the blocks") to the specific ("the Recent Status Update block"), and your response confirms that it is the default blocks that you are asking about. The 'fix' is to use custom blocks instead, as follows (note: I am not providing what you put in to every field, I am providing the specific things that need to be done...the rest is up to you) ACP Pages -> Blocks -> Create Block In the second field ('Plugin') select the block you want to use ('Recent Status Updates') Give it a name (example: myBlock) Save this Pages -> Blocks -> Create Block This time, choose 'Custom' -> 'Manual HTML' On the first tab, name your custom block On the 'Content' tab, insert the code below On the same tab, DO NOT enable 'Cache this block' Save the new custom block Now, on the front-end you put that custom block in place, instead of the 'Recent Status Updates' block {{if \IPS\Request::i()->controller==='page' AND !isset(\IPS\Request::i()->id)}} {block="myBlock"} {{endif}} Why do it this way? The 'Recent Status Updates' block is cached, so adding the {{if....}} statement in its content will end up with strange caching results. Result (there may be some finesse needed, but there is your starting point): Amazing, it worked perfectly! Thanks I only had two problems... 1. When I tried to replicate in "Popular contributors" disappeared the names. 2. In version 4.6.0 it worked, but in my 4.5.4.2 there was a space
Nathan Explosion Posted June 15, 2021 Posted June 15, 2021 15 minutes ago, Hisashi said: 2. In version 4.6.0 it worked, but in my 4.5.4.2 there was a space You won't have access to this linked content, but it's an issue that is fixed in (as you found) 4.6.0: Hisashi 1
Hisashi Posted June 15, 2021 Author Posted June 15, 2021 7 minutes ago, Nathan Explosion said: You won't have access to this linked content, but it's an issue that is fixed in (as you found) 4.6.0: What a pity 😔 Thank you anyway, helped me a lot! When I finish my adjustments I update the version. Do you have any solution for Popular contributors?
Nathan Explosion Posted June 15, 2021 Posted June 15, 2021 36 minutes ago, Hisashi said: 1. When I tried to replicate in "Popular contributors" disappeared the names. Unfortunately, I think that block has a little JS code that acts against it and the above method isn't compatible. That specific block could probably be handled via a template edit instead (not fully tested - I'm going to bed): core -> front -> widgets -> mostContributors Enclose the template content with the following: {{if \IPS\Request::i()->controller==='page' AND !isset(\IPS\Request::i()->id)}} ALL THE EXISTING TEMPLATE {{endif}} 4 minutes ago, Hisashi said: Do you have any solution for Popular contributors? Was typing it up as you replied - hope it works as I think it might. Hisashi 1
Hisashi Posted June 16, 2021 Author Posted June 16, 2021 17 hours ago, Nathan Explosion said: Unfortunately, I think that block has a little JS code that acts against it and the above method isn't compatible. That specific block could probably be handled via a template edit instead (not fully tested - I'm going to bed): core -> front -> widgets -> mostContributors Enclose the template content with the following: {{if \IPS\Request::i()->controller==='page' AND !isset(\IPS\Request::i()->id)}} ALL THE EXISTING TEMPLATE {{endif}} Didn't work
Nathan Explosion Posted June 16, 2021 Posted June 16, 2021 (edited) As I said - I was tired hehe 17 hours ago, Nathan Explosion said: (not fully tested - I'm going to bed) The correct template for that widget is actually core -> front -> widgets -> topContributors However, the suggested theme edit won't work because this widget is cached too. Unfortunately, I think you're out of luck on this one specifically. Edited June 16, 2021 by Nathan Explosion
opentype Posted June 16, 2021 Posted June 16, 2021 As I said in the beginning: Just create two independent pages like I did. Hisashi 1
Hisashi Posted June 16, 2021 Author Posted June 16, 2021 2 hours ago, opentype said: As I said in the beginning: Just create two independent pages like I did. I just didn't understand how I do it that way. I create two pages (being one main) The main I put the blocks other the database That's it?
Hisashi Posted June 16, 2021 Author Posted June 16, 2021 (edited) I managed to do it in another way with the idea of @opentype I'll leave it here as a help, in case anyone looks for... ---------1. Create two pages (Manual HTML), one with a sidebar that you will mark as main page The other without sidebar (On this page you will place the database) 2. Create a new block as per a screenshot Here you put your database (Don't enable "Cache this block") 3. Now go to your main page and place the block with the database you just created. Now just add your blocks in sidebar and when you click it won't show. Thank you @Nathan Explosion for the other way to do this. Edited June 16, 2021 by Hisashi
Recommended Posts