Skip to content

Instantly share code, notes, and snippets.

@katzueno
Created July 19, 2015 11:23
Show Gist options
  • Save katzueno/f7deb2e62eed645bbe0b to your computer and use it in GitHub Desktop.
Save katzueno/f7deb2e62eed645bbe0b to your computer and use it in GitHub Desktop.
Display the number of the pages with a particular topic value in concrete5.7
// 5.6 の場合
Loader::model('page_list');
$pl = new PageList();
$pl->filterByAttribute('attr_name','attr_value','like');
echo $pl->getTotal();
// 5.7 でトピック属性
// /application/blocks/topic_list/view.php
// クラスを読み込み
$pageList = new \Concrete\Core\Page\PageList();
// 以下をループ
$pagesOfATopic = $pageList->filterByTopic($topic); // ここ
$result = $pageList->getTotalResults($pagesOfATopic);
echo $result; // ここでそのトピックを持っているページの数を出力
// 他に使えるオプション
/*
filterByPageTypeHandle();
filterByPageTemplate();
filterByDateAdded();
filterByNumberOfChildren();
filterByUserID($uID);
filterByPageTypeID($ptID);
filterByParentID($cParentID);
filterByName($name, $exact = false);
filterByKeywords($keywords)
filterByFulltextKeywords($keywords);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment