Davyc Posted July 25, 2022 Posted July 25, 2022 I'm looking to add the following code to a template: {{$date = \IPS\DateTime::ts( strtotime( $movie->release_date ) );}} <div class="date1">{datetime="$date"}</div> The idea is to only show the release date of a movie on a specific page ID - in this instance it would be page-id='15' I'm presuming that this needs to be wrapped in an {{if}} statement, but the syntax goes above my level of understanding of IPS code. With thanks for any assistance.
Martin A. Posted July 25, 2022 Posted July 25, 2022 {{if \IPS\cms\Pages\Page::$currentPage and \IPS\cms\Pages\Page::$currentPage->id == 15}} YOUR CODE {{endif}} SeNioR- and Davyc 1 1
Davyc Posted July 25, 2022 Author Posted July 25, 2022 @Martin A. Many thanks for that, but unfortunately this is not an IPS Pages app so that code will not work. I'm presuming the code snippet for the movies for the release date to show is: {{if $movie->status == 'Released'}} <li class="ipsDataItem"> <span class="ipsDataItem_generic ipsDataItem_size3"><strong>{lang="movie_release_date"}</strong></span> {{$date = \IPS\DateTime::ts( strtotime( $movie->release_date ) );}} <span class="ipsDataItem_generic">{datetime="$date"}</span> </li> {{endif}} I need an extra parameter to show that only on a certain page, in this instance page 15. With thanks
Nathan Explosion Posted July 25, 2022 Posted July 25, 2022 What type of page is it then? Forums? Blogs? different app? Provide a link to it - the html content will assist with finding out much more about the page than you've given so far. Davyc 1
Davyc Posted July 25, 2022 Author Posted July 25, 2022 (edited) Here you go @Nathan Explosion https://moviebuffs.org/movies/category/15-coming-soon/ Forgot to day it's Adriano's Movies App Edited July 25, 2022 by Davyc
Nathan Explosion Posted July 25, 2022 Posted July 25, 2022 (edited) <body class="ipsApp ipsApp_front ipsJS_none ipsClearfix" data-controller="core.front.core.app" data-message="" data-pageapp="movies" data-pagelocation="front" data-pagemodule="movies" data-pagecontroller="browse" data-pageid="15" > Try this: {{if \IPS\Request::i()->app =='movies AND \IPS\Request::i()->id =='15'}} {{endif}} Or if the template is part of the movies app itself, then just this: {{if \IPS\Request::i()->id =='15'}} {{endif}} Edited July 25, 2022 by Nathan Explosion SeNioR- and Davyc 1 1
Davyc Posted July 25, 2022 Author Posted July 25, 2022 Perfect - second code snippet did the trick. Many, many thanks for helping out it's very much appreciated. @Nathan Explosion and @Martin A.
Recommended Posts