ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

best way to handle sidebar?

November 04, 2011 4:30pm

Subscribe [2]
  • #1 / Nov 04, 2011 4:30pm

    Riverboy

    2993 posts

    Hi, i use embed:foobar and then modify the template if needed to add/remove something.
    But i was wondering is there a more simple way to handle all, cos i have 2-4 actual templates that i embed into sidebar of my sites pages, some has 2 some 4.

    cheers
    -pete

  • #2 / Nov 04, 2011 5:44pm

    Rob Allen

    3114 posts

    If I have a sidebar that could have 3 or 4 different blocks depending what pages it’s being displayed on, I’ll often use one embed and inside it add a conditional or two depending what I want to show. Other times however I will embed 2 or 3 templates - it really depends on the needs of the site, what’s easiest to manage, and of course what is most efficient.

  • #3 / Nov 04, 2011 5:58pm

    Riverboy

    2993 posts

    can you give some simple example how you would do that? thanks.

  • #4 / Nov 04, 2011 6:57pm

    Rob Allen

    3114 posts

    Ok, call a single embed…

    {embed='inc/.sidebar'}

    Then in the .sidebar template

    <aside id="sidebar">
    
    {!-- only show on the home page --}
    {if segment_1 == ""}
    Hello and welcome to my home page
    {/if}
    
    {!-- show categories always, no conditional --}
    <h2>Categories</h2>
    <p>{exp:channel:categories channel="blog"}<br />
    <a href="http://{path=blog/index}">{category_name}</a><br />
    {/exp:channel:categories}</p>
    
    <p>{!-- only show recent posts if not in the blog section --}<br />
    {if segment_1 != "blog"}</p><h2>Recent posts</h2>
    <p><ul><br />
    {exp:channel:entries channel="blog" dynamic="off" limit="5"}<br />
    <li><a href="http://{url_title_path=blog/story}">{title}</a></li><br />
    {/exp:channel:entries}</ul><br />
    {/if}</p>
    
    <p></aside>

    Does that give you an idea Pete?

     

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases