Jump to content

Add code to template


Recommended Posts

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.

Link to comment
Share on other sites

@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

Link to comment
Share on other sites

<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 by Nathan Explosion
Link to comment
Share on other sites

  • Recently Browsing   0 members

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