本文整理匯總了PHP中Items::retrieveById方法的典型用法代碼示例。如果您正苦於以下問題:PHP Items::retrieveById方法的具體用法?PHP Items::retrieveById怎麽用?PHP Items::retrieveById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Items
的用法示例。
在下文中一共展示了Items::retrieveById方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executeDetail
public function executeDetail()
{
$id = $this->get('id');
if (!$id || !($item = \Items::retrieveById($id))) {
return $this->raise404(t('Product Category not found!'));
}
$term = $item->getCat();
$this->setView('Products/item_detail');
$this->view()->assign(['item' => $item, 'term' => $term]);
return $this->renderComponent();
}
示例2: beforeExecute
public function beforeExecute()
{
parent::beforeExecute();
// TODO: Change the autogenerated stub
$document = $this->document();
$document->title = \Setting::get('site_name');
$this->_initTemplate();
$this->_initLanguages();
Plugin::addFilter('custom_router_param', function ($route, $params) {
if ('products/category' == $route) {
if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
$params['slug'] = $term->getSlug();
}
}
if ('products/detail' == $route) {
if (isset($params['id']) && ($item = \Items::retrieveById($params['id']))) {
$params['slug'] = $item->getSlug();
}
}
return $params;
}, 1, 2);
}