Iskander001 Posted April 11, 2016 Posted April 11, 2016 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.
Colonel_mortis Posted April 11, 2016 Posted April 11, 2016 {{$isForumIndex = \IPS\Dispatcher::i()->application->directory === 'forums' && \IPS\Dispatcher::i()->module === 'forums' && \IPS\Dispatcher::i()->controller === 'index';}} should work, though I haven't tested it.
Iskander001 Posted April 11, 2016 Author Posted April 11, 2016 {{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
Iskander001 Posted April 11, 2016 Author Posted April 11, 2016 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.
Iskander001 Posted April 11, 2016 Author Posted April 11, 2016 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
SeNioR- Posted July 8, 2016 Posted July 8, 2016 I use: {{if (\IPS\Request::i()->url()->data['path']) == "/"}} Code only on Homepage {[endif}}
Gabriel Torres Posted March 7, 2019 Posted March 7, 2019 The solution provided by @SeNioR- worked like a charm here!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.