Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
switcher.phtml
Go to the documentation of this file.
1 <?php
7 // @codingStandardsIgnoreFile
8 
9 ?>
10 <?php
14 ?>
15 <?php if ($block->isShow()): ?>
16 <div class="field field-store-switcher">
17  <label class="label" for="store_switcher"><?= /* @escapeNotVerified */ __('Show Report For:') ?></label>
18  <div class="control">
19  <select
20  id="store_switcher"
21  class="admin__control-select"
22  name="store_switcher"
23  onchange="return switchStore(this);">
24  <option value=""><?= /* @escapeNotVerified */ __('All Websites') ?></option>
25  <?php foreach ($block->getWebsiteCollection() as $_website): ?>
26  <?php $showWebsite = false; ?>
27  <?php foreach ($block->getGroupCollection($_website) as $_group): ?>
28  <?php $showGroup = false; ?>
29  <?php foreach ($block->getStoreCollection($_group) as $_store): ?>
30  <?php if ($showWebsite == false): ?>
31  <?php $showWebsite = true; ?>
32  <option website="true" value="<?= /* @escapeNotVerified */ $_website->getId() ?>"<?php if ($block->getRequest()->getParam('website') == $_website->getId()): ?> selected<?php endif; ?>>
33  <?= /* @escapeNotVerified */ $_website->getName() ?>
34  </option>
35  <?php endif; ?>
36  <?php if ($showGroup == false): ?>
37  <?php $showGroup = true; ?>
38  <option group="true" value="<?= /* @escapeNotVerified */ $_group->getId() ?>"<?php if ($block->getRequest()->getParam('group') == $_group->getId()): ?> selected<?php endif; ?>>&nbsp;&nbsp;&nbsp;<?= /* @escapeNotVerified */ $_group->getName() ?></option>
39  <?php endif; ?>
40  <option value="<?= /* @escapeNotVerified */ $_store->getId() ?>"<?php if ($block->getStoreId() == $_store->getId()): ?> selected<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?= /* @escapeNotVerified */ $_store->getName() ?></option>
41  <?php endforeach; ?>
42  <?php endforeach; ?>
43  <?php endforeach; ?>
44  </select>
45  </div>
46  <?= $block->getHintHtml() ?>
47 </div>
48 <script>
49 require(['prototype'], function(){
50 
51  switchStore = function(obj){
52  if (obj.options[obj.selectedIndex].getAttribute('website') == 'true') {
53  var selectionType = 'website';
54  } else if (obj.options[obj.selectedIndex].getAttribute('group') == 'true') {
55  var selectionType = 'group';
56  } else {
57  var selectionType = 'store';
58  }
59  var storeParam = obj.value ? selectionType + '/' + obj.value + '/' : '';
60  if(obj.switchParams){
61  storeParam+= obj.switchParams;
62  }
63  setLocation('<?= /* @escapeNotVerified */ $block->getSwitchUrl() ?>'+storeParam);
64  }
65 
66 });
67 </script>
68 <?php endif; ?>
if( $websites=$block->getWebsites())(__( 'Choose Store View:')) ?></label >< div class $showWebsite
Definition: store.phtml:20
$block setTitle( 'CMS Block Title') -> setIdentifier('fixture_block') ->setContent('< h1 >Fixture Block Title</h1 >< a href=" store url</a><p> Config value
Definition: block.php:9
__()
Definition: __.php:13
$block
Definition: block.php:8
$_count $_index $_prevOptionId if($block->getOrderOptions()|| $_item->getDescription()) foreach( $items as $_item)( $_item) ?><?php $attributes if( $_item->getOrderItem() ->getParentItem())($_prevOptionId !=$attributes['option_id'])</td >< td > & nbsp
Definition: renderer.phtml:33
foreach($block->getWebsiteCollection() as $_website) foreach($block->getGroupCollection($_website) as $_group) foreach( $block->getStoreCollection( $_group) as $_store)($showWebsite==false) if($block->getRequest() ->getParam('website')==$_website->getId()) endif
Definition: switcher.phtml:21
if($block->getStoreId()==$_store->getId()) endforeach
Definition: switcher.phtml:28