Jump to content

How to check if we are on homepage ?


Iskander001

Recommended Posts

Posted

Hello Everyone.

In my globalTemplate i want to check either we are viewing the home page or not.

In my scenario i have a slider block which i put in globalTemplate and i want to check if the page is home page then show the slider and if not then just print out ips_container.

In IPB 3.4.x there is a option like $test = $this->registry->ccsFunctions->getPageName(), so it will return the page name with extension like index.html.

So guys what options are available in new 4.1.1.0 version, that will do this job.

Thanks. Much Appreciated your Kind Help.

Posted

{{if $isForumIndex = \IPS\Dispatcher::i()->application->directory === 'cms' && \IPS\Dispatcher::i()->module === 'pages' && \IPS\Dispatcher::i()->controller === 'page' && \IPS\Dispatcher::i()->view === 'home'}}
HomePage
{{else}}
Not HomePage
{{endif}}

Basically i want the current page which is set to default page, In my case my default page name is home, so i have to first get the name and then check if its true.

I have slightly modified your code, but not working for me. Kindly check if you could find any mistakes in it.

Thanks.

Regards

 

Posted

On this forum someone have also tried this out in this way : 

$location['app'] == 'cms' and $location['module'] == 'pages' and $location['controller'] == 'page' and \IPS\Request::i()->id == x}}

where my page id is 10. 

But still no success.

Please Help Thanks.

Posted

Thanks for your help. 

I am somehow get this in working with following code.

{{if $home = \IPS\cms\Pages\Page::$currentPage->id == 10}}
home
{{else}}
nothome
{{endif}}

 

Regards

  • 2 months later...
  • 2 years later...

Archived

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...