Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Right Sidebar If Statements

Quote Reply
Right Sidebar If Statements
In the right sidebar I want to use different content for different pages. How would I write an if statements to identify pages.

Example -
if page is home page
display this information
if not
display this information

Along with the proper syntax what is the common page names to use?
Quote Reply
Re: [jgkiefer] Right Sidebar If Statements In reply to
The original page that was loaded (eg. home.html, category.html, etc) is stored in the page_id template variable (minus the .extension, so home.html turns into home). So you can do <%if page_id eq 'home'%>...<%endif%>

Adrian
Quote Reply
Re: [brewt] Right Sidebar If Statements In reply to
Thanks!
Quote Reply
Re: [brewt] Right Sidebar If Statements In reply to
What if statement would be used to to display information only in the category right sidebar?
Quote Reply
Re: [jgkiefer] Right Sidebar If Statements In reply to
I think I posted this before, but the solution I found that works "best" for me, is to add _home to the various segments of the home template, and duplicate the include files, such as:

include_right_sidebar_home.html

Because the home page, detail pages, and often search/new/cool pages are formatted differently from the "category" pages, I've also created the same sort of region files for each.

include_right_sidebar.html is the "default" file.

The other sidebar files can be customized, or left empty, or simply <%include include_right_sidebar.html%>

Editing the .css file to give different formatting to those regions gives you some extra control as well.

I have found this works *best* for us, because when I'm trying to make a change to the site, I can easily and visually find the include_right_sidebar_NNNNN.html file, and the related .css block. Any changes to that one block will not affect the others, but changes to the default formatting affect all the blocks.

I've also found it helpful to separate out many of the home page regions, and create new <div> or other blocks using the _home extension to the tags.

That way, I can have a different formatting on the home page, and another format for the site-wide pages.

I've found it less confusing than trying to use nested if/else or other constructs for this particular situation.

This is -different- than trying to show different content or formatting based on topics (eg: modifying a single template to do different things). This is formatting by _region_ (page, page-block, content-block), and creating different regions and named blocks makes a lot of sense when you think about how you "visualize" or conceptualize your site layout.

I'm sure there are clever ways of using the page-name tag and if/else blocks to append the formatting tags, but that is overkill for what I needed. In setting up about 20-25 sites with GL3, and converting another couple of dozen sites, separating out the _home page/blocks from the rest of the site covered over 90% of the formatting situations we've run into. _search is over half the other situations, since customized search results and 3rd party pull results are often used, so different formatting is needed.

In short: using if/else blocks to load different content based on _template_ is not as good a solution as using them within a template to simply load different content (eg: categories, topics, themes). We've found it better to modify the base templates, then use default <%include ...%> to load default content. It's worked out as easier to maintain. Since the major templates (home, category, link, xxx_sidebar, headers, etc) are going to be modified and stored in the local folder anyway, and the luna.css is preserved through upgrades, it doesn't impose any additional burdon, and actually makes "thinking" about the site's layout easier (*especially* if you are setting up or maintaining multiple sites).

Just a few side-ways thoughts :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Right Sidebar If Statements In reply to
I have discovered this also as the easiest solution. I found your naming and ccs handling very interesting and informative. I am always looking for ways to make things easier. Thank you.