[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/templates/cassiopeia/ -> index.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  Templates.cassiopeia
   6   *
   7   * @copyright   (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  defined('_JEXEC') or die;
  12  
  13  use Joomla\CMS\Factory;
  14  use Joomla\CMS\HTML\HTMLHelper;
  15  use Joomla\CMS\Language\Text;
  16  use Joomla\CMS\Uri\Uri;
  17  
  18  /** @var Joomla\CMS\Document\HtmlDocument $this */
  19  
  20  $app = Factory::getApplication();
  21  $wa  = $this->getWebAssetManager();
  22  
  23  // Browsers support SVG favicons
  24  $this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon.svg', '', [], true, 1), 'icon', 'rel', ['type' => 'image/svg+xml']);
  25  $this->addHeadLink(HTMLHelper::_('image', 'favicon.ico', '', [], true, 1), 'alternate icon', 'rel', ['type' => 'image/vnd.microsoft.icon']);
  26  $this->addHeadLink(HTMLHelper::_('image', 'joomla-favicon-pinned.svg', '', [], true, 1), 'mask-icon', 'rel', ['color' => '#000']);
  27  
  28  // Detecting Active Variables
  29  $option   = $app->input->getCmd('option', '');
  30  $view     = $app->input->getCmd('view', '');
  31  $layout   = $app->input->getCmd('layout', '');
  32  $task     = $app->input->getCmd('task', '');
  33  $itemid   = $app->input->getCmd('Itemid', '');
  34  $sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
  35  $menu     = $app->getMenu()->getActive();
  36  $pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : '';
  37  
  38  // Color Theme
  39  $paramsColorName = $this->params->get('colorName', 'colors_standard');
  40  $assetColorName  = 'theme.' . $paramsColorName;
  41  $wa->registerAndUseStyle($assetColorName, 'media/templates/site/cassiopeia/css/global/' . $paramsColorName . '.css');
  42  
  43  // Use a font scheme if set in the template style options
  44  $paramsFontScheme = $this->params->get('useFontScheme', false);
  45  $fontStyles       = '';
  46  
  47  if ($paramsFontScheme) {
  48      if (stripos($paramsFontScheme, 'https://') === 0) {
  49          $this->getPreloadManager()->preconnect('https://fonts.googleapis.com/', ['crossorigin' => 'anonymous']);
  50          $this->getPreloadManager()->preconnect('https://fonts.gstatic.com/', ['crossorigin' => 'anonymous']);
  51          $this->getPreloadManager()->preload($paramsFontScheme, ['as' => 'style', 'crossorigin' => 'anonymous']);
  52          $wa->registerAndUseStyle('fontscheme.current', $paramsFontScheme, [], ['media' => 'print', 'rel' => 'lazy-stylesheet', 'onload' => 'this.media=\'all\'', 'crossorigin' => 'anonymous']);
  53  
  54          if (preg_match_all('/family=([^?:]*):/i', $paramsFontScheme, $matches) > 0) {
  55              $fontStyles = '--cassiopeia-font-family-body: "' . str_replace('+', ' ', $matches[1][0]) . '", sans-serif;
  56              --cassiopeia-font-family-headings: "' . str_replace('+', ' ', isset($matches[1][1]) ? $matches[1][1] : $matches[1][0]) . '", sans-serif;
  57              --cassiopeia-font-weight-normal: 400;
  58              --cassiopeia-font-weight-headings: 700;';
  59          }
  60      } else {
  61          $wa->registerAndUseStyle('fontscheme.current', $paramsFontScheme, ['version' => 'auto'], ['media' => 'print', 'rel' => 'lazy-stylesheet', 'onload' => 'this.media=\'all\'']);
  62          $this->getPreloadManager()->preload($wa->getAsset('style', 'fontscheme.current')->getUri() . '?' . $this->getMediaVersion(), ['as' => 'style']);
  63      }
  64  }
  65  
  66  // Enable assets
  67  $wa->usePreset('template.cassiopeia.' . ($this->direction === 'rtl' ? 'rtl' : 'ltr'))
  68      ->useStyle('template.active.language')
  69      ->useStyle('template.user')
  70      ->useScript('template.user')
  71      ->addInlineStyle(":root {
  72          --hue: 214;
  73          --template-bg-light: #f0f4fb;
  74          --template-text-dark: #495057;
  75          --template-text-light: #ffffff;
  76          --template-link-color: #2a69b8;
  77          --template-special-color: #001B4C;
  78          $fontStyles
  79      }");
  80  
  81  // Override 'template.active' asset to set correct ltr/rtl dependency
  82  $wa->registerStyle('template.active', '', [], [], ['template.cassiopeia.' . ($this->direction === 'rtl' ? 'rtl' : 'ltr')]);
  83  
  84  // Logo file or site title param
  85  if ($this->params->get('logoFile')) {
  86      $logo = '<img src="' . Uri::root(true) . '/' . htmlspecialchars($this->params->get('logoFile'), ENT_QUOTES) . '" alt="' . $sitename . '">';
  87  } elseif ($this->params->get('siteTitle')) {
  88      $logo = '<span title="' . $sitename . '">' . htmlspecialchars($this->params->get('siteTitle'), ENT_COMPAT, 'UTF-8') . '</span>';
  89  } else {
  90      $logo = HTMLHelper::_('image', 'logo.svg', $sitename, ['class' => 'logo d-inline-block'], true, 0);
  91  }
  92  
  93  $hasClass = '';
  94  
  95  if ($this->countModules('sidebar-left', true)) {
  96      $hasClass .= ' has-sidebar-left';
  97  }
  98  
  99  if ($this->countModules('sidebar-right', true)) {
 100      $hasClass .= ' has-sidebar-right';
 101  }
 102  
 103  // Container
 104  $wrapper = $this->params->get('fluidContainer') ? 'wrapper-fluid' : 'wrapper-static';
 105  
 106  $this->setMetaData('viewport', 'width=device-width, initial-scale=1');
 107  
 108  $stickyHeader = $this->params->get('stickyHeader') ? 'position-sticky sticky-top' : '';
 109  
 110  // Defer fontawesome for increased performance. Once the page is loaded javascript changes it to a stylesheet.
 111  $wa->getAsset('style', 'fontawesome')->setAttribute('rel', 'lazy-stylesheet');
 112  ?>
 113  <!DOCTYPE html>
 114  <html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
 115  <head>
 116      <jdoc:include type="metas" />
 117      <jdoc:include type="styles" />
 118      <jdoc:include type="scripts" />
 119  </head>
 120  
 121  <body class="site <?php echo $option
 122      . ' ' . $wrapper
 123      . ' view-' . $view
 124      . ($layout ? ' layout-' . $layout : ' no-layout')
 125      . ($task ? ' task-' . $task : ' no-task')
 126      . ($itemid ? ' itemid-' . $itemid : '')
 127      . ($pageclass ? ' ' . $pageclass : '')
 128      . $hasClass
 129      . ($this->direction == 'rtl' ? ' rtl' : '');
 130  ?>">
 131      <header class="header container-header full-width<?php echo $stickyHeader ? ' ' . $stickyHeader : ''; ?>">
 132  
 133          <?php if ($this->countModules('topbar')) : ?>
 134              <div class="container-topbar">
 135              <jdoc:include type="modules" name="topbar" style="none" />
 136              </div>
 137          <?php endif; ?>
 138  
 139          <?php if ($this->countModules('below-top')) : ?>
 140              <div class="grid-child container-below-top">
 141                  <jdoc:include type="modules" name="below-top" style="none" />
 142              </div>
 143          <?php endif; ?>
 144  
 145          <?php if ($this->params->get('brand', 1)) : ?>
 146              <div class="grid-child">
 147                  <div class="navbar-brand">
 148                      <a class="brand-logo" href="<?php echo $this->baseurl; ?>/">
 149                          <?php echo $logo; ?>
 150                      </a>
 151                      <?php if ($this->params->get('siteDescription')) : ?>
 152                          <div class="site-description"><?php echo htmlspecialchars($this->params->get('siteDescription')); ?></div>
 153                      <?php endif; ?>
 154                  </div>
 155              </div>
 156          <?php endif; ?>
 157  
 158          <?php if ($this->countModules('menu', true) || $this->countModules('search', true)) : ?>
 159              <div class="grid-child container-nav">
 160                  <?php if ($this->countModules('menu', true)) : ?>
 161                      <jdoc:include type="modules" name="menu" style="none" />
 162                  <?php endif; ?>
 163                  <?php if ($this->countModules('search', true)) : ?>
 164                      <div class="container-search">
 165                          <jdoc:include type="modules" name="search" style="none" />
 166                      </div>
 167                  <?php endif; ?>
 168              </div>
 169          <?php endif; ?>
 170      </header>
 171  
 172      <div class="site-grid">
 173          <?php if ($this->countModules('banner', true)) : ?>
 174              <div class="container-banner full-width">
 175                  <jdoc:include type="modules" name="banner" style="none" />
 176              </div>
 177          <?php endif; ?>
 178  
 179          <?php if ($this->countModules('top-a', true)) : ?>
 180          <div class="grid-child container-top-a">
 181              <jdoc:include type="modules" name="top-a" style="card" />
 182          </div>
 183          <?php endif; ?>
 184  
 185          <?php if ($this->countModules('top-b', true)) : ?>
 186          <div class="grid-child container-top-b">
 187              <jdoc:include type="modules" name="top-b" style="card" />
 188          </div>
 189          <?php endif; ?>
 190  
 191          <?php if ($this->countModules('sidebar-left', true)) : ?>
 192          <div class="grid-child container-sidebar-left">
 193              <jdoc:include type="modules" name="sidebar-left" style="card" />
 194          </div>
 195          <?php endif; ?>
 196  
 197          <div class="grid-child container-component">
 198              <jdoc:include type="modules" name="breadcrumbs" style="none" />
 199              <jdoc:include type="modules" name="main-top" style="card" />
 200              <jdoc:include type="message" />
 201              <main>
 202              <jdoc:include type="component" />
 203              </main>
 204              <jdoc:include type="modules" name="main-bottom" style="card" />
 205          </div>
 206  
 207          <?php if ($this->countModules('sidebar-right', true)) : ?>
 208          <div class="grid-child container-sidebar-right">
 209              <jdoc:include type="modules" name="sidebar-right" style="card" />
 210          </div>
 211          <?php endif; ?>
 212  
 213          <?php if ($this->countModules('bottom-a', true)) : ?>
 214          <div class="grid-child container-bottom-a">
 215              <jdoc:include type="modules" name="bottom-a" style="card" />
 216          </div>
 217          <?php endif; ?>
 218  
 219          <?php if ($this->countModules('bottom-b', true)) : ?>
 220          <div class="grid-child container-bottom-b">
 221              <jdoc:include type="modules" name="bottom-b" style="card" />
 222          </div>
 223          <?php endif; ?>
 224      </div>
 225  
 226      <?php if ($this->countModules('footer', true)) : ?>
 227      <footer class="container-footer footer full-width">
 228          <div class="grid-child">
 229              <jdoc:include type="modules" name="footer" style="none" />
 230          </div>
 231      </footer>
 232      <?php endif; ?>
 233  
 234      <?php if ($this->params->get('backTop') == 1) : ?>
 235          <a href="#top" id="back-top" class="back-to-top-link" aria-label="<?php echo Text::_('TPL_CASSIOPEIA_BACKTOTOP'); ?>">
 236              <span class="icon-arrow-up icon-fw" aria-hidden="true"></span>
 237          </a>
 238      <?php endif; ?>
 239  
 240      <jdoc:include type="modules" name="debug" style="none" />
 241  </body>
 242  </html>


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer