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


PHP CategoryModel::getGroup方法代码示例

本文整理汇总了PHP中CategoryModel::getGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP CategoryModel::getGroup方法的具体用法?PHP CategoryModel::getGroup怎么用?PHP CategoryModel::getGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CategoryModel的用法示例。


在下文中一共展示了CategoryModel::getGroup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _showCategory

 /**
  * Displays a category.
  *
  * @param CategoryModel $category
  *
  * @throws HttpException
  * @return null
  */
 private function _showCategory(CategoryModel $category)
 {
     $group = $category->getGroup();
     if (!$group) {
         Craft::log('Attempting to preview a category that doesn’t have a group', LogLevel::Error);
         throw new HttpException(404);
     }
     craft()->setLanguage($category->locale);
     // Have this category override any freshly queried categories with the same ID/locale
     craft()->elements->setPlaceholderElement($category);
     craft()->templates->getTwig()->disableStrictVariables();
     $this->renderTemplate($group->template, array('category' => $category));
 }
开发者ID:jmstan,项目名称:craft-website,代码行数:21,代码来源:CategoriesController.php

示例2: fields

 /**
  * Parse category fields.
  *
  * @param CategoryModel $category
  * @param bool          $empty
  *
  * @return array
  */
 public function fields(CategoryModel $category, $empty = false)
 {
     // Always save id
     $fields = array('id' => array('label' => Craft::t('ID'), 'value' => $category->id), 'title' => array('label' => Craft::t('Title'), 'value' => (string) $category->getTitle()), 'group' => array('label' => Craft::t('Group'), 'value' => (string) $category->getGroup()));
     // Get element type
     $elementType = craft()->elements->getElementType(ElementType::Category);
     // Get nice attributes
     $availableAttributes = $elementType->defineAvailableTableAttributes();
     // Make 'em fit
     $attributes = array();
     foreach ($availableAttributes as $key => $result) {
         $attributes[$key] = $result['label'];
     }
     // Get static "fields"
     foreach ($category->getAttributes() as $handle => $value) {
         // Only show nice attributes
         if (array_key_exists($handle, $attributes)) {
             $fields[$handle] = array('label' => $attributes[$handle], 'value' => StringHelper::arrayToString(is_array($value) ? array_filter(ArrayHelper::flattenArray($value), 'strlen') : $value, ', '));
         }
     }
     // Get fieldlayout
     foreach (craft()->fields->getLayoutByType(ElementType::Category)->getFields() as $field) {
         // Get field values
         $field = $field->getField();
         $handle = $field->handle;
         $label = $field->name;
         $value = $empty ? '' : craft()->auditLog->parseFieldData($handle, $category->{$handle});
         // Set on fields
         $fields[$handle] = array('label' => $label, 'value' => $value);
     }
     // Return
     return $fields;
 }
开发者ID:boboldehampsink,项目名称:auditlog,代码行数:41,代码来源:AuditLog_CategoryService.php


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