10375 Posts in 2190 Topics by 1707 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1328 Views |
-
Embargo / Expiry still displays blog posts in BlogHolder page

23 November 2009 at 10:03pm
So I know that this module is being phased out but I'm asking anyway. Embargo / Expiry works very well but it won't hide blog posts that are set to embargo. Is there anyway to stop blog previews from showing up in the BlogHolder page?
function canView($member) {} ??? works fro blogPage but not for BlogHolder??
Thanks.
-
Re: Embargo / Expiry still displays blog posts in BlogHolder page

11 December 2009 at 5:22pm
Just got a reply from Simon Welsh, the author of the Embargo/Expiry Module. Thanks Simon that's a HUGE help.
It's to do with the BlogHolder not checking canView() on each of its children that it displays. I'm basing this off of the 0.2.1 release of the blog module.
In blog/code/BlogHolder.php, find (in the Entries method in the BlogHolder class):
return DataObject::get("Page","`ParentID` = $this->ID $tagCheck $dateCheck","`BlogEntry`.Date DESC",'',"$limit");
replace with:
$items = DataObject::get("Page","`ParentID` = $this->ID $tagCheck $dateCheck","`BlogEntry`.Date DESC");
$newSet = new DataObjectSet();
foreach($items as $item) {
if($item->canView()) $newSet->push($item);
}
if($limit) {
list($start, $length) = split(' *, *', $limit);
if(!$length) {
return $newSet->getRange(0, $start);
}
return $newSet->getRange($start, $length);
}
return $newSet; -
Re: Embargo / Expiry still displays blog posts in BlogHolder page

13 December 2009 at 12:31pm
okay now I've just discovered that the Blog Pagination has disappeared after changing the codeas shown above.
Any suggestions?
-
Re: Embargo / Expiry still displays blog posts in BlogHolder page

3 July 2010 at 3:12am Last edited: 3 July 2010 3:13am
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.
Cheers
Lamin -
Re: Embargo / Expiry still displays blog posts in BlogHolder page

17 November 2010 at 11:10am Last edited: 17 November 2010 11:13am
The canView/Template method works great unless you're trying to limit the amount of records pulled in, in which case the records are filtered after the fact. If you want a replacement method to call you can add a BlogTreeDecorator and put these two methods inside...
function ViewableEntries($limit = '', $tag = '', $date = '') {
return $this->owner->Entries($limit, $tag, $date, array($this, 'canViewEntries'));
}
function canViewEntries($className, $filter, $limit, $order) {if (class_exists('EmbargoExpiryDecorator')) {
$date = date('Y-m-d H:i:s');
$embargo = " AND (Embargo IS NULL OR Embargo <= '$date')";
$expiry = " AND (Expiry IS NULL OR Expiry >= '$date')";
$filter .= $embargo . $expiry;
}
return DataObject::get('BlogEntry', $filter, $order, '', $limit);
}Then you can call ViewableEntries(4) in your template and get back exactly 4 viewable results.
| 1328 Views | ||
|
Page:
1
|
Go to Top |



