当前位置: 首页>>代码示例>>PHP>>正文


PHP AkrecipesFrontendHelper::getItemIdByAlias方法代码示例

本文整理汇总了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;
 }
开发者ID:rutvikd,项目名称:ak-recipes,代码行数:91,代码来源:router.php


注:本文中的AkrecipesFrontendHelper::getItemIdByAlias方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。