Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Page.php
Go to the documentation of this file.
1 <?php
7 
10 
15 class Page extends View\Result\Page
16 {
23  public function setActiveMenu($itemId)
24  {
26  $menuBlock = $this->layout->getBlock('menu');
27  $menuBlock->setActive($itemId);
28  $parents = $menuBlock->getMenuModel()->getParentItems($itemId);
29  foreach ($parents as $item) {
31  $this->getConfig()->getTitle()->prepend($item->getTitle());
32  }
33  return $this;
34  }
35 
44  public function addBreadcrumb($label, $title, $link = null)
45  {
47  $block = $this->layout->getBlock('breadcrumbs');
48  if ($block) {
49  $block->addLink($label, $title, $link);
50  }
51  return $this;
52  }
53 
60  public function addContent(View\Element\AbstractBlock $block)
61  {
62  return $this->moveBlockToContainer($block, 'content');
63  }
64 
71  public function addLeft(View\Element\AbstractBlock $block)
72  {
73  return $this->moveBlockToContainer($block, 'left');
74  }
75 
82  public function addJs(View\Element\AbstractBlock $block)
83  {
84  return $this->moveBlockToContainer($block, 'js');
85  }
86 
96  protected function moveBlockToContainer(View\Element\AbstractBlock $block, $containerName)
97  {
98  $this->layout->setChild($containerName, $block->getNameInLayout(), '');
99  return $this;
100  }
101 }
$title
Definition: default.phtml:14
addLeft(View\Element\AbstractBlock $block)
Definition: Page.php:71
$block
Definition: block.php:8
addJs(View\Element\AbstractBlock $block)
Definition: Page.php:82
$label
Definition: details.phtml:21
addContent(View\Element\AbstractBlock $block)
Definition: Page.php:60
moveBlockToContainer(View\Element\AbstractBlock $block, $containerName)
Definition: Page.php:96