I'm looking for advice for the best way to handle this. I have a custom index.tpl, so I can certainly take care of it in there, but I was hoping to not have to code for every individual staticpage url.
Any suggestions appreciated.
Suppress sidebar for staticpage(s)
Re: Suppress sidebar for staticpage(s)
Since you mention that, I'll assume you know how to do that (code it for every single static page). If you don't, just hollergizmola wrote:I'm looking for advice for the best way to handle this. I have a custom index.tpl, so I can certainly take care of it in there, but I was hoping to not have to code for every individual staticpage url.
Anyway, you could try just checking for $staticpage_pagetitle:
Code: Select all
{if $staticpage_pagetitle}
YL
Re: Suppress sidebar for staticpage(s)
Such a simple solution. Thanks much, it worked perfectly.
-
- Posts: 1
- Joined: Sat Aug 01, 2009 5:03 am
Re: Suppress sidebar for staticpage(s)
I need to do this too. Suppress the sidebars from showing on a static page. I'm not a programmer but I can follow simple instructions.
I don't understand what was explained above. Is it possible to suppress only the sidebars of 1 particular static page? (I have a few)
What is the code I should be looking for and changing?
Thank you guys.
I don't understand what was explained above. Is it possible to suppress only the sidebars of 1 particular static page? (I have a few)
What is the code I should be looking for and changing?
Thank you guys.
Re: Suppress sidebar for staticpage(s)
So in a nutshell, the main control file of a template is the index.tpl file. This file is typically written in smarty syntax, so it's going to be a mix of html and smarty. This file can have whatever the original designer wanted it to have, and there's lots of different approaches so there's no universal answer to your question, but it could be as easy as in my case, simply checking for the existence of the static page title variable and not rendering that div if it exists. In the template I based my modification on, there was this originally:
So I simply used the suggested title variable to suppress this block, using smarty's IF construct.
One other quick tip I can provide you, that's unrelated but that I utilized, and is fairly well know, is that a template can have a config.inc.php file, where you can add variables for use in the template files. In the same template I have a page that uses some javascript for a gallery. I only wanted to have this javascript injected on that page, and while there are other ways to do this with some plugins, I chose to just code it into the index.tpl.
So in the config.inc.php I grab the uri from php, and set a smarty template variable:
And in the index.tpl, in the section that emits the html head tag:
Hope these couple of tips steer you in the right direction. In case you weren't sure, the template files are all in serendipity main directory under the /templates/{template name} directory.
One last tip I can offer, just in general terms of working with smarty, is that smarty basically compiles the .tpl files into .php scripts. These compiled scripts go into the /templates_c directory. When you're modifying .tpl files, sometimes you can get some weird issues where smarty doesn't recompile the scripts. so it's good to know where the cached versions are. If you get into any issues where your changes are not showing up, just delete the cached files in the templates_c directory.
Code: Select all
<div id="sidebar">
{serendipity_printSidebar side="right"}
{serendipity_printSidebar side="left"}
</div>
Code: Select all
{if !$staticpage_pagetitle}
<div id="sidebar">
{serendipity_printSidebar side="right"}
{serendipity_printSidebar side="left"}
</div>
{/if}
So in the config.inc.php I grab the uri from php, and set a smarty template variable:
Code: Select all
$serendipity['smarty']->assign(array('curruri' => $_SERVER['REQUEST_URI']));
Code: Select all
{if $curruri == '/pages/photos.html'}
// Here is include an additional .css and some javascript code I need.
One last tip I can offer, just in general terms of working with smarty, is that smarty basically compiles the .tpl files into .php scripts. These compiled scripts go into the /templates_c directory. When you're modifying .tpl files, sometimes you can get some weird issues where smarty doesn't recompile the scripts. so it's good to know where the cached versions are. If you get into any issues where your changes are not showing up, just delete the cached files in the templates_c directory.