Esempio n. 1
0
 /**
  * {@inheritDoc}
  *
  * Renders menu's associated block.
  *
  * This method will look for certain view elements when rendering each menu, if
  * one of this elements is not present it'll look the next one, and so on. These
  * view elements should be defined by Themes by placing them in
  * `<MyTheme>/Template/Element`.
  *
  * ### Render menu based on theme's region & view-mode
  *
  *     render_menu_[region-name]_[view-mode].ctp
  *
  * Renders the given block based on theme's `region-name` and `view-mode`, for
  * example:
  *
  * - `render_menu_left-sidebar_full.ctp`: Render for menus in `left-sidebar`
  *    region when view-mode is `full`.
  *
  * - `render_menu_left-sidebar_search-result.ctp`: Render for menus in
  *   `left-sidebar` region when view-mode is `search-result`
  *
  * - `render_menu_footer_search-result.ctp`: Render for menus in `footer` region
  *   when view-mode is `search-result`.
  *
  * ### Render menu based on theme's region
  *
  *     render_menu_[region-name].ctp
  *
  * Similar as before, but based only on theme's `region` (and any view-mode), for
  * example:
  *
  * - `render_menu_right-sidebar.ctp`: Render for menus in `right-sidebar`
  *   region.
  *
  * - `render_menu_left-sidebar.ctp`: Render for menus in `left-sidebar`
  *   region.
  *
  * ### Default
  *
  *     render_block.ctp
  *
  * This is the default render, if none of the above is found we try to use this
  * last. Themes can overwrite this view element by creating a new one
  * at `ExampleTheme/Template/Element/render_block.ctp`.
  *
  * ---
  *
  * NOTE: Please note the difference between "_" and "-"
  */
 public function render(Block $block, View $view)
 {
     $menuId = intval($block->settings['menu_id']);
     $menu = TableRegistry::get('Menu.Menus')->find()->cache("info_{$menuId}", 'menus')->where(['Menus.id' => $menuId])->first();
     $links = TableRegistry::get('Menu.MenuLinks')->find('threaded')->cache("links_{$menuId}", 'menus')->where(['menu_id' => $menuId])->order(['lft' => 'ASC']);
     $menu->set('links', $links);
     $viewMode = $view->viewMode();
     $blockRegion = isset($block->region->region) ? $block->region->region : 'none';
     $cacheKey = "render_{$blockRegion}_{$viewMode}";
     $cache = static::cache($cacheKey);
     $element = 'Menu.render_menu';
     if ($cache !== null) {
         $element = $cache;
     } else {
         $try = ["Menu.render_menu_{$blockRegion}_{$viewMode}", "Menu.render_menu_{$blockRegion}", 'Menu.render_menu'];
         foreach ($try as $possible) {
             if ($view->elementExists($possible)) {
                 $element = static::cache($cacheKey, $possible);
                 break;
             }
         }
     }
     return $view->element($element, compact('menu'));
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public function viewModeSettings(FieldInstance $instance, View $view, $viewMode)
 {
     return $view->element('Field.DateField/view_mode_form', compact('instance', 'viewMode'));
 }
 /**
  * {@inheritDoc}
  */
 public function render(Block $block, View $view)
 {
     return $view->element('Content.Widget/dashboard_search_render', compact('block'));
 }
Esempio n. 4
0
 /**
  * {@inheritDoc}
  */
 public function viewModeSettings(FieldInstance $instance, View $view, $viewMode)
 {
     return $view->element('Taxonomy.taxonomy_field_view_mode_form', compact('instance'));
 }
 /**
  * {@inheritDoc}
  *
  * This method will look for certain view elements when rendering each custom
  * block, if one of this elements is not present it'll look the next one, and so
  * on. These view elements should be defined by Themes by placing them in
  * `<MyTheme>/Template/Element`.
  *
  * ### Render block based on theme's region & view-mode
  *
  *     render_block_[region-name]_[view-mode].ctp
  *
  * Renders the given block based on theme's **region-name and view-mode**, for
  * example:
  *
  * - render_block_left-sidebar_full.ctp: Render for blocks in `left-sidebar`
  *   region when view-mode is `full`
  *
  * - render_block_left-sidebar_search-result.ctp: Render for blocks in
  *   `left-sidebar` region when view-mode is `search-result`.
  *
  * - render_block_footer_search-result.ctp: Render for blocks in `footer`
  *   region when view-mode is `search-result`.
  *
  *
  * ### Render block based on theme's region
  *
  *     render_block_[region-name].ctp
  *
  * Similar as before, but based on theme's **region-name** (and any view-mode),
  * for example:
  *
  * - render_block_right-sidebar.ctp: Render for blocks in `right-sidebar` region.
  *
  * - render_block_left-sidebar.ctp: Render for blocks in `left-sidebar` region.
  *
  *
  * ### Default
  *
  *     render_block.ctp
  *
  * This is the global render, if none of the above renders is found we try to
  * use this last. Themes can overwrite this view element by creating a new one
  * at `ExampleTheme/Template/Element/render_block.ctp`.
  *
  * ---
  *
  * NOTE: Please note the difference between "_" and "-"
  */
 public function render(Block $block, View $view)
 {
     $viewMode = $view->viewMode();
     $blockRegion = isset($block->region->region) ? 'none' : $block->region->region;
     $cacheKey = "render_{$block->id}_{$blockRegion}_{$viewMode}";
     $cache = static::cache($cacheKey);
     $element = 'Block.render_block';
     if ($cache !== null) {
         $element = $cache;
     } else {
         $try = ["Block.render_block_{$blockRegion}_{$viewMode}", "Block.render_block_{$blockRegion}", 'Block.render_block'];
         foreach ($try as $possible) {
             if ($view->elementExists($possible)) {
                 $element = static::cache($cacheKey, $possible);
                 break;
             }
         }
     }
     return $view->element($element, compact('block', 'options'));
 }
 /**
  * {@inheritDoc}
  */
 public function render(Block $block, View $view)
 {
     $contents = TableRegistry::get('Content.Contents')->find('all', ['fieldable' => false])->order(['created' => 'DESC'])->limit(10)->all();
     return $view->element('Content.Widget/dashboard_latest_content_render', compact('block', 'contents'));
 }
Esempio n. 7
0
 /**
  * {@inheritDoc}
  */
 public function render(Block $block, View $view)
 {
     return $view->element('User.user_menu_widget_render', compact('block'));
 }
 /**
  * {@inheritDoc}
  */
 public function settings(Block $block, View $view)
 {
     return $view->element('Taxonomy.categories_widget_settings', compact('block'));
 }
 /**
  * {@inheritDoc}
  */
 public function settings(Block $block, View $view)
 {
     $languagesList = LocaleToolbox::languagesList(false, false);
     return $view->element('Locale.language_switcher_widget_settings', compact('block', 'languagesList'));
 }
 /**
  * {@inheritDoc}
  */
 public function settings(Block $block, View $view)
 {
     return $view->element('Content.Widget/recent_content_settings', compact('block'));
 }