Hide sidebar section on particular pages?
Hide sidebar section on particular pages?
I was wondering if there is a way to hide a sidebar section on specific pages. For example, I have a Blogroll page, and a blogroll sidebar widget (using html_nugget), and I'd like the sidebar blogroll to be hidden only when viewing the Blogroll page.
Re: Hide sidebar section on particular pages?
Technically yes, but it's not going to be a “nice and easy” solution (as far as I can see). It will require hacking your theme's template files, it will only work if you use only the one html nugget, and it will likely break if you ever switch themes.Christine wrote:I was wondering if there is a way to hide a sidebar section on specific pages. For example, I have a Blogroll page, and a blogroll sidebar widget (using html_nugget), and I'd like the sidebar blogroll to be hidden only when viewing the Blogroll page.
The problem with this is twofold
- There is no good way in template files which static page you're currently on. There is a way to identify a static page (I assume your blogroll is a static page and not an entry?), but that might change if you edit the (title of the) static page.
- There is no good way to identify a single sidebar plugin if said plugin can be installed multiple times (which the html nugget can be).
If you prefer an easy solution, I would suggest to just replace the sidebar blogroll with a link to the blogroll page.
YL
Re: Hide sidebar section on particular pages?
I do have a few html nuggets, so I guess that's out!
I was also hoping to hide another html nugget on the start page - I guess this would at least avoid the issues with the static page, but there is still the problem of having multiple html nuggets. Would copying the html nugget plugin and giving it a new name work for this?
It's not that crucial but I'm just curious now.
I've decided this is best, as the Blogroll made the sidebar look too crowded.yellowled wrote:
If you prefer an easy solution, I would suggest to just replace the sidebar blogroll with a link to the blogroll page.
I was also hoping to hide another html nugget on the start page - I guess this would at least avoid the issues with the static page, but there is still the problem of having multiple html nuggets. Would copying the html nugget plugin and giving it a new name work for this?
It's not that crucial but I'm just curious now.
Re: Hide sidebar section on particular pages?
Not sure if I understand what you mean by that, but if you're thinking of copying a plugin like copying a theme (with a changed name), I'm not sure if that would work. (But I never thought of trying that, either.)Christine wrote:Would copying the html nugget plugin and giving it a new name work for this?
Sorry we don't have a good solution for this, but this is an edge case.
YL
Re: Hide sidebar section on particular pages?
I have done it before following advice on here. It works, the only issue is if there are any crucial updates to a plugin, you'd have to maybe copy and customise it again.yellowled wrote: Not sure if I understand what you mean by that, but if you're thinking of copying a plugin like copying a theme (with a changed name), I'm not sure if that would work. (But I never thought of trying that, either.)
That's OK!yellowled wrote: Sorry we don't have a good solution for this, but this is an edge case.
But to keep it simpler, if I wanted to hide a unique plugin, say the Linklist... is there any easy way to do that?
Re: Hide sidebar section on particular pages?
Not emitting a plugin is actually pretty simple if it's only one plugin. For example, I do this in the sidebar.tpl of 2k11 for quicksearch because 2k11 has a “hardcoded” search form in the header and no blog needs two search forms.Christine wrote:But to keep it simpler, if I wanted to hide a unique plugin, say the Linklist... is there any easy way to do that?
Code: Select all
{foreach from=$plugindata item=item}
{if $item.class != "serendipity_plugin_quicksearch"}
<section class="sidebar_plugin clearfix {cycle values="odd,even"} {$item.class}">
{if $item.title != ""}
<h3>{$item.title}</h3>
{/if}
<div class="sidebar_content clearfix">{$item.content}</div>
</section>
{/if}
{/foreach}
The hard part is to find a reliable identifier for the page on which you do not want to emit a given plugin. Even harder: this identifier (i.e. a variable that we can test in our template file) has to be available in sidebar.tpl, which is not the case for all variables in s9y.
So if you know which plugin you want to hide on which page, we can see if there's a way to hide it or not. I'm afraid there is no easy solution that will work for any plugin on any page of the blog.
YL
Re: Hide sidebar section on particular pages?
Thank you! I managed to hide the Linklist plugin on my Links page using:
ETA:
If I wanted to hide other plugins on different pages, would I just use {else if} and adjust the first line? Or is there another way?
Code: Select all
{if $item.class == "serendipity_plugin_linklist" && $staticpage_pagetitle == "Links"}
<!-- hide linklist -->
{else}
[my sidebar code here]
{/if}
If I wanted to hide other plugins on different pages, would I just use {else if} and adjust the first line? Or is there another way?
Re: Hide sidebar section on particular pages?
Yes, but note that it's {elseif} in Smarty (one word). Smarty does not have a better control structures for that (like other languages do).Christine wrote:If I wanted to hide other plugins on different pages, would I just use {else if} and adjust the first line?
YL