Jump to content

Determining page in template

Featured Replies

Posted

Hi there,

I've been scouting through the documentation trying to find variables a template has access too - haven't been able to find anything too helpful.

Basically in my template i'm wanting to change the layout slightly if their on the home page.

Hello,

Could you explain more better please so I can try to help. :)

Kind Regards,

Carlos S.

  • Author

For example like in Wordpress there is is_front_page() (https://codex.wordpress.org/Function_Reference/is_front_page) 

So in my global template i'd want to have something like

 

{{ if is_front_page }}
         <h1>Something that only shows up on the home page</h1>
{{ endif }}

 

I'm also using the Pages application

I can't offer any concrete advice on how to go about pulling this off, but each Pages article has its own id number (page_id in table cms_pages). I would think there's some way of targeting along the lines of an if-clause looking for data-pageapp=cms, data-pagelocation=front, data-pagemodule=pages and data-pageid=xx.

I'm way outside my comfort zone with this sort of advice but it might help spur someone more knowledgeable than me to complete the answer, so I thought I'd post it anyway :)

  • Author

I can't offer any concrete advice on how to go about pulling this off, but each Pages article has its own id number (page_id in table cms_pages). I would think there's some way of targeting along the lines of an if-clause looking for data-pageapp=cms, data-pagelocation=front, data-pagemodule=pages and data-pageid=xx.

I'm way outside my comfort zone with this sort of advice but it might help spur someone more knowledgeable than me to complete the answer, so I thought I'd post it anyway :)

Thank you very much, there doesn't seem to much documentation around this which is a bit of a shame.

Once I work it out i'll reply back here

  • Author

Using a hack.. Found a temporary solution using  {{if \IPS\Request::i()->url() == "xxx"}} do something {{endif}} but is not ideal for other pages

i believe you can do this by activating developer mode and adding (print) trigger to the page

scroll down to - Display template contents to read instructions

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.