silverstripe-blog/extensions/BlogPostFilter.php
2013-08-04 17:38:26 +01:00

18 lines
368 B
PHP
Executable File

<?php
class BlogPostFilter extends DataExtension {
/**
* Augment queries so that we don't fetch unpublished articles.
**/
public function augmentSQL(SQLQuery &$query) {
$stage = Versioned::current_stage();
if($stage == "Stage") $stage = "";
else $stage = "_" . Convert::raw2sql($stage);
$query->addWhere("PublishDate < NOW()");
}
}