different template for non index pages?
  • How can I change the page's layout if it's not the index page?
    So basically, I want to remove my S2 (Pensee du jour) and S3 (Quoi de neuf?) section in the left sidebar when I'm not in the index page. Please take a look at the 2 screenshots to get what I mean.
    I thought I could compare the URL_MAIN template tags variables to check if it was the main page and display the sidebar or not but that didn't work the way I used it:

    <?php if ($URL_MAIN == "http://mysite.com") { ?>
    <%php echo "this is the main page" ?>
    <?php }else{ ?>
    <%php echo "this is NOT the main page" ?>
    <?php } ?>


    but that failed miserably. Using the curly braces around the URL_MAIN variable is also a no go within the IF sentence since it's a reserved character in PHP.

    so what can I do?

    thanks!! :)

    PS. I absolutely love making a new TangoCMS theme! So freakin' easy it's scary.
  • Hey,

    That theme is looking pretty cool! Good work.

    For what you're wanting to do, this is actually going to be part of 2.3.0 (it is already implemented and working very well, see http://dev.tangocms.org/issues/show/54 "Different layout on pages"). So once released (roughly 1 month) you can very easily do it via the Content Layout Module.

    As for now though, you can use the $page_id PHP variable to test against. When at the frontpage its value will be 'frontpage' - so do exactly as you're doing but just change the var to $page_id and compare to 'frontpage'. Another way of doing it is to use the Router library to get the actual URL, so something like:

    <?php if ( $this->_router->get_current_url() == '' ) { ... }

    If you use that way though, it will break when you upgrade to 2.3.0 since the method names have all changed. In 2.3.0 you'd use
    <?php if ( $this->_router->getRequestPath() == '' ) { ... }

    Both of those methods will return something such as 'page/index/foobar'

    Hope that helps
  • thanks Alex.

    that worked great!

    The new theme will be up soon and I'll probably write a small tutorial on how to make our own theme. Is it something that you guys have done yet?
  • Glad it worked. No we haven't, though once 2.3 is released we're going to be focusing on documentation - which you're more than welcome to help out with
  • I'd love to know where this feature is located. I've been all over Content Layout and can't find it.
  • Hi Snooze,

    If you go to the "Content Layout" module, you'll then see a table with by default 2 layouts in. You can add new layouts and give them a different URL (you can use PCRE regex to match against), that way you can configure the layout for many different URLs.
  • Ah. I wondered about that.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion