Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Blog Module /

Discuss the Blog Module.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Entries expires function

Go to End

3 Posts   1553 Views


Community Member, 49 Posts

6 November 2009 at 3:46am

I've added an expire function for the entries so that they will not show if the date has expired. This works just fine, but I'm trying to add more function to it so that it will show entries when it comes to a date.

But I can't get this to work..
The code for the expiry function I got from the embargo/expire module.

Here's what I have so far:

	function ExpiresDoNotShow() {
		if (Director::urlParam('Action') && Director::urlParam('Action') != "tag" ) {
		return true;
		$now = strtotime('now');
		if($this->owner->Date && strtotime($this->owner->Date) > $now) {
			return false;
		} elseif($this->owner->DateOut && strtotime($this->owner->DateOut) < $now) {
			return false;
		} else {
		 	return true;

If I remove else return true, nothing outputs.
When true is set the entries that doesn't have expired shows.

Need some help with this.



Community Member, 49 Posts

6 November 2009 at 10:20pm

lol.. I feel like such a newbie..
I've been trying to get this to work for two days now, not been able to figure out why this isn't working when the code is right.
And I just figured out why.. I've set the in date for the entries last month, so no wonder they all show up. lol..

So.. this is solved.. :)

Lamin Barrow

Community Member, 22 Posts

3 July 2010 at 3:30am

I had the same problem too but mine wasn't associated with the BlogHolder. I was using custom page types and using a dataobject::get to get my custom pages in a paginated view.

Actually, there is an easy fix to this. Instead of modifying the core code, you can just edit your BlogHolder templates files and it should work painlessly as expect.

Like this.

<% control BlogPosts %>
<% if canView %>

<!-- The Post here -->

<% end_if %>
<% end_control %>

The embargo and expiring modules comes with the canView function. As you can see, you can use it in your template to filter posted based which posted get seen (you would see everything regardless of embargo or expiry restrictions if you are an admin) based on the embargo and expiry restriction.

I hope this helps.