Suppress sidebar for staticpage(s)

Skinning and designing Serendipity (CSS, HTML, Smarty)
Post Reply
gizmola
Regular
Posts: 37
Joined: Mon Oct 25, 2004 11:54 pm

Suppress sidebar for staticpage(s)

Post by gizmola »

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.
yellowled
Regular
Posts: 7111
Joined: Fri Jan 13, 2006 11:46 am
Location: Eutin, Germany
Contact:

Re: Suppress sidebar for staticpage(s)

Post by yellowled »

gizmola 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.
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 holler :)

Anyway, you could try just checking for $staticpage_pagetitle:

Code: Select all

{if $staticpage_pagetitle}
However, that might as well trigger for some pages generated by plugins (download manager et. al.), but not for static pages on which the page title wasn't set.

YL
gizmola
Regular
Posts: 37
Joined: Mon Oct 25, 2004 11:54 pm

Re: Suppress sidebar for staticpage(s)

Post by gizmola »

Such a simple solution. Thanks much, it worked perfectly.
ferrariboy
Posts: 1
Joined: Sat Aug 01, 2009 5:03 am

Re: Suppress sidebar for staticpage(s)

Post by ferrariboy »

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.
gizmola
Regular
Posts: 37
Joined: Mon Oct 25, 2004 11:54 pm

Re: Suppress sidebar for staticpage(s)

Post by gizmola »

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:

Code: Select all

      
        <div id="sidebar">
            {serendipity_printSidebar side="right"}
            {serendipity_printSidebar side="left"}
        </div>
So I simply used the suggested title variable to suppress this block, using smarty's IF construct.

Code: Select all

        {if !$staticpage_pagetitle}  
        <div id="sidebar">
            {serendipity_printSidebar side="right"}
            {serendipity_printSidebar side="left"}
        </div>
        {/if}
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:

Code: Select all

$serendipity['smarty']->assign(array('curruri' => $_SERVER['REQUEST_URI'])); 
And in the index.tpl, in the section that emits the html head tag:

Code: Select all

{if $curruri == '/pages/photos.html'} 
// Here is include an additional .css and some javascript code I need.
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.
Post Reply