3060 Posts in 864 Topics by 646 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1309 Views |
-
Expires.InPast not working right

22 October 2009 at 9:02pm
I've been trying to make the InPast function to work.
$Expires.InPast outputs 1 when its out of date, but when I run a <% if Expires.InPast %>..<% end_if %> it doesn't to anything with it and shows every article..
Any idea why or what I'm doing wrong?
-
Re: Expires.InPast not working right

26 November 2009 at 7:33am
I am banging my head against the wall on this problem, too!
Did you find a solution? If so, I would be very interested in what you came up with! Thanks in advance.
-
Re: Expires.InPast not working right

7 December 2009 at 1:10pm
Hmmm... Lots of people seem to be having trouble getting this to work. I never have needed to use it, so I can't say from experience where the issue lies. However, i do have a solution.
Simply, when you do this on an item, it will be a property of a DataObject, so we can simply build a method into the model called 'hasExpired'.
Simply in the model we need to create a method:
class Page extends SiteTree {
...
public function hasExpired() {
return (strtotime($this->Date) < time());
}
}Now, in your template you can do:
<% if hasExpired %>
...
<% end_if %>Obviously 'Date' will have to be declared in the $db array with date type
I hope that helps
| 1309 Views | ||
|
Page:
1
|
Go to Top |




