本文整理汇总了PHP中AkrecipesFrontendHelper::getItemIdByAlias方法的典型用法代码示例。如果您正苦于以下问题:PHP AkrecipesFrontendHelper::getItemIdByAlias方法的具体用法?PHP AkrecipesFrontendHelper::getItemIdByAlias怎么用?PHP AkrecipesFrontendHelper::getItemIdByAlias使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AkrecipesFrontendHelper
的用法示例。
在下文中一共展示了AkrecipesFrontendHelper::getItemIdByAlias方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: parse
/**
* Parse method for URLs
* This method is meant to transform the human readable URL back into
* query parameters. It is only executed when SEF mode is switched on.
*
* @param array &$segments The segments of the URL to parse.
*
* @return array The URL attributes to be used by the application.
*
* @since 3.3
*/
public function parse(&$segments)
{
error_log("IN AkrecipesRouter::parse segments == " . print_r($segments, true));
$vars = array();
$total = count($segments);
// if segment is 1, then it is a recipe
if ($total == 1) {
// check if it is contests or brands list
switch ($segments[0]) {
case 'contests':
$vars['view'] = 'contests';
break;
case 'brands':
$vars['view'] = 'brands';
break;
default:
$vars['view'] = 'recipe';
// $model = AkrecipesFrontendHelper::getModel($vars['view']);
// $id = $model->getItemIdByAlias($segments[0]);
$id = AkrecipesFrontendHelper::getItemIdByAlias($segments[0], 'recipe');
$vars['id'] = $id;
break;
}
return $vars;
} elseif ($total == 2) {
// check if it is a contest/brand page. If not assume it is category
$iscat = false;
$table_name = null;
switch ($segments[0]) {
case 'contests':
$vars['view'] = 'contest';
$table_name = 'contests';
break;
case 'brands':
$vars['view'] = 'brand';
$table_name = 'brands';
break;
case 'author':
$vars['view'] = 'recipesbyuser';
$table_name = 'users';
break;
default:
$iscat = true;
break;
}
if (!$iscat) {
// $model = AkrecipesFrontendHelper::getModel($vars['view']);
// $id = $model->getItemIdByAlias($segments[1]);
$id = AkrecipesFrontendHelper::getItemIdByAlias($segments[1], $table_name);
$vars['id'] = $id;
return $vars;
}
}
// reached here, assume it is a category
// We get the category id from the menu item and search from there
$id = $item->query['id'];
$category = JCategories::getInstance('Akrecipes')->get($id);
if (!$category) {
JError::raiseError(404, JText::_('COM_CONTENT_ERROR_PARENT_CATEGORY_NOT_FOUND'));
return $vars;
}
$categories = $category->getChildren();
$vars['catid'] = $id;
$vars['id'] = $id;
$vars['layout'] = 'blog';
$found = 0;
foreach ($segments as $segment) {
$segment = str_replace(':', '-', $segment);
foreach ($categories as $category) {
if ($category->alias == $segment) {
$vars['id'] = $category->id;
$vars['view'] = 'recipes';
$categories = $category->getChildren();
$found = 1;
break;
}
}
}
return $vars;
}