本文整理汇总了PHP中PageList::sortByPublicDate方法的典型用法代码示例。如果您正苦于以下问题:PHP PageList::sortByPublicDate方法的具体用法?PHP PageList::sortByPublicDate怎么用?PHP PageList::sortByPublicDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageList
的用法示例。
在下文中一共展示了PageList::sortByPublicDate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPageList
public function getPageList()
{
Loader::model('page_list');
$db = Loader::db();
$bID = $this->bID;
if ($this->bID) {
$q = 'select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btPageList where bID = \'' . $bID . '\'';
$r = $db->query($q);
if ($r) {
$row = $r->fetchRow();
}
} else {
$row['num'] = $this->num;
$row['cParentID'] = $this->cParentID;
$row['cThis'] = $this->cThis;
$row['orderBy'] = $this->orderBy;
$row['ctID'] = $this->ctID;
$row['rss'] = $this->rss;
$row['displayAliases'] = $this->displayAliases;
}
$pl = new PageList();
$pl->setNameSpace('b' . $this->bID);
$cArray = array();
switch ($row['orderBy']) {
case 'display_asc':
$pl->sortByDisplayOrder();
break;
case 'display_desc':
$pl->sortByDisplayOrderDescending();
break;
case 'chrono_asc':
$pl->sortByPublicDate();
break;
case 'alpha_asc':
$pl->sortByName();
break;
case 'alpha_desc':
$pl->sortByNameDescending();
break;
case 'random':
$pl->sortBy('RAND()');
break;
default:
$pl->sortByPublicDateDescending();
break;
}
$num = (int) $row['num'];
$pl->setItemsPerPage($num);
$c = Page::getCurrentPage();
if (is_object($c)) {
$this->cID = $c->getCollectionID();
}
Loader::model('attribute/categories/collection');
if ((int) $this->displayFeaturedOnly === 1) {
$cak = CollectionAttributeKey::getByHandle('is_featured');
if (is_object($cak)) {
$pl->filterByIsFeatured(1);
}
}
if (!$row['displayAliases']) {
$pl->filterByIsAlias(0);
}
$pl->filter('cvName', '', '!=');
if ($row['ctID']) {
$pl->filterByCollectionTypeID($row['ctID']);
}
$columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable());
if (isset($columns['AK_EXCLUDE_PAGE_LIST'])) {
$pl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
}
if (intval($row['cParentID']) != 0) {
$cParentID = $row['cThis'] ? $this->cID : $row['cParentID'];
if ($this->includeAllDescendents) {
$pl->filterByPath(Page::getByID($cParentID)->getCollectionPath());
} else {
$pl->filterByParentID($cParentID);
}
}
return $pl;
}
示例2: getPages
function getPages($query = null)
{
Loader::model('page_list');
$db = Loader::db();
$bID = $this->bID;
if ($this->bID) {
$q = "select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btEasyNewsList where bID = '{$bID}'";
$r = $db->query($q);
if ($r) {
$row = $r->fetchRow();
}
} else {
$row['num'] = $this->num;
$row['cParentID'] = $this->cParentID;
$row['cThis'] = $this->cThis;
$row['orderBy'] = $this->orderBy;
$row['ctID'] = $this->ctID;
$row['rss'] = $this->rss;
}
$pl = new PageList();
$pl->setNameSpace('b' . $this->bID);
$cArray = array();
switch ($row['orderBy']) {
case 'public_desc':
$pl->sortBy('cvDatePublic', 'desc');
break;
case 'public_asc':
$pl->sortBy('cvDatePublic', 'asc');
break;
case 'display_asc':
$pl->sortByDisplayOrder();
break;
case 'display_desc':
$pl->sortByDisplayOrderDescending();
break;
case 'chrono_asc':
$pl->sortByPublicDate();
break;
case 'alpha_asc':
$pl->sortByName();
break;
case 'alpha_desc':
$pl->sortByNameDescending();
break;
default:
$pl->sortByPublicDateDescending();
break;
}
$num = (int) $row['num'];
if ($num > 0) {
$pl->setItemsPerPage($num);
}
$c = Page::getCurrentPage();
if (is_object($c)) {
$this->cID = $c->getCollectionID();
}
$cParentID = $row['cThis'] ? $this->cID : $row['cParentID'];
Loader::model('attribute/categories/collection');
if ($this->displayFeaturedOnly == 1) {
$cak = CollectionAttributeKey::getByHandle('is_featured');
if (is_object($cak)) {
$pl->filterByIsFeatured(1);
}
}
if (!$row['displayAliases']) {
$pl->filterByIsAlias(0);
}
$pl->filter('cvName', '', '!=');
if ($row['ctID']) {
$pl->filterByCollectionTypeID($row['ctID']);
}
$columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable());
if (isset($columns['AK_EXCLUDE_PAGE_LIST'])) {
$pl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
}
if (intval($row['cParentID']) != 0) {
$pl->filterByParentID($cParentID);
}
//Publish Date Filter
$dt = Loader::helper('date');
$pl->filter('cvDatePublic', $dt->getLocalDateTime(), '<');
if ($num > 0) {
$pages = $pl->getPage();
} else {
$pages = $pl->get();
}
$this->set('pl', $pl);
return $pages;
}
示例3: PageList
}
$pl = new PageList();
$pl->setNameSpace('b' . $bID);
/*
* Apply filters
*/
// Sort results
switch ($row['orderBy']) {
case 'display_asc':
$pl->sortByDisplayOrder();
break;
case 'display_desc':
$pl->sortByDisplayOrderDescending();
break;
case 'chrono_asc':
$pl->sortByPublicDate();
break;
case 'alpha_asc':
$pl->sortByName();
break;
case 'alpha_desc':
$pl->sortByNameDescending();
break;
default:
$pl->sortByPublicDateDescending();
break;
}
// Filter by is_featured attribute
if ($row['displayFeaturedOnly'] == 1) {
Loader::model('attribute/categories/collection');
$cak = CollectionAttributeKey::getByHandle('is_featured');