Skip to content

Instantly share code, notes, and snippets.

@danielkmariam
Created September 6, 2013 13:41
Show Gist options
  • Save danielkmariam/6463955 to your computer and use it in GitHub Desktop.
Save danielkmariam/6463955 to your computer and use it in GitHub Desktop.
/**
* Returns the collection of posts
*
* @param array $categorySlugs Slug value of categories
* @param array $tagSlugs Slug value of tags
*
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
*/
public function getPosts($categorySlugs = array(), $tagSlugs = array(), $filter=false)
{
return $this->_getPostCollection($categorySlugs, $tagSlugs, $filter);
}
/**
* Generates and returns the collection of posts
*
* @return Fishpig_Wordpress_Model_Mysql4_Post_Collection
*/
protected function _getPostCollection($categorySlugs = array(), $tagSlugs = array(), $filter=false)
{
if (is_null($this->_postCollection)) {
if (is_null($this->getWrapperBlock()) === false) {
$this->_postCollection = $this->getWrapperBlock()->getPostCollection();
if (count($categorySlugs) > 0 && $filter) {
var_dump('>>> fter');
$this->getWrapperBlock()->setPostListTemplate('wordpress/post/list.phtml');
$this->_postCollection->addExcludeCategoryAndTagSlugFilter($categorySlugs, $tagSlugs);
}
if ($this->getPagerBlock() && $this->_postCollection) {
$this->getPagerBlock()->setCollection($this->_postCollection);
}
}
}
return $this->_postCollection;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment