daily pastebin goal
19%
SHARE
TWEET

Bootstrap4 Nav

stom66 Nov 14th, 2017 (edited) 16 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {*
  2. *   Template name: Bootstrap4 Nav
  3. *   -------------------------------------
  4. *
  5. *   This is the default template for use with the "Navigator" module. It is capable of generating
  6. *   the three stock Bootstrap Navbar types: default, static and fixed. It can also be customised
  7. *   with the included Bootstrap4 classes for light and dark.
  8.  
  9. *   Customisations should be made in the "Bootstrap4 Settings" template and NOT in this file, and
  10. *   the following can be done there:
  11. *
  12. *    - Change navbar position
  13. *    - Change navbar brand text
  14. *    - Change navbar brand logo
  15. *    - Change toggler alignment
  16. *    - Switch dark/light Bootstrap theme
  17. *
  18. *   Note: this template should be set as the "default" template of its type for the Bootstrap4 theme
  19. *
  20. *   Part of the CMSMS Bootstrap4 template by stom | stom66.co.uk
  21. *}
  22. {$default_navbar_style = $default_navbar_style|default:"default" scope=global}
  23. {function name=Nav_menu depth=1}{strip}
  24.     {foreach $data as $node}
  25.         {* setup classes for the anchor and list item *}
  26.         {assign var='liclass' value='nav-item'}
  27.  
  28.         {if $depth < 1}
  29.             {assign var='aclass' value='nav-link'}
  30.         {else}
  31.             {assign var='aclass' value='dropdown-item'}
  32.         {/if}
  33.  
  34.         {if $node->current}
  35.             {assign var='liclass' value=$liclass|cat:' active'}
  36.             {assign var='aclass' value=$aclass|cat:' active'}
  37.         {/if}
  38.  
  39.         {if $node->parent}
  40.             {assign var='liclass' value=$liclass|cat:' active'}
  41.             {assign var='aclass' value=$aclass|cat:' active'}
  42.         {/if}
  43.  
  44.         {if $node->children_exist && $depth < 1}
  45.             {assign var='liclass' value=$liclass|cat:' dropdown'}
  46.             {assign var='aclass' value=$aclass|cat:' dropdown-toggle'}
  47.         {/if}
  48.  
  49.         {* build the menu item node *}
  50.         {if $node->type == 'sectionheader'}
  51.             {if $depth < 1}<li class='{if $depth>0}-header{/if} {$liclass}'>{/if}
  52.             {if isset($node->children) && ($depth == 0)}
  53.                 <a  href="#" class="{$aclass}" id="nav-link-{$node->id}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  54.                     {$node->menutext} <span class="caret"></span>
  55.                 </a>
  56.                 <div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-link-{$node->id}">
  57.                     {Nav_menu data=$node->children depth=$depth+1}
  58.                 </div>
  59.             {else}
  60.                 <h6 class="dropdown-header">{$node->menutext}</h6>
  61.             {/if}
  62.             {if $depth < 1}</li>{/if}
  63.         {else if $node->type == 'separator'}
  64.             {if $depth < 1}<li role="separator" class='divider {$liclass}'></li>{/if}
  65.         {else}
  66.             {* regular item *}
  67.             {if $depth < 1}<li class="{$liclass}">{/if}
  68.             {if isset($node->children) && ($depth == 0)}
  69.                 <a  href="#" class="{$aclass}" id="nav-link-{$node->id}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  70.                     {$node->menutext} <span class="caret"></span>
  71.                 </a>
  72.                 <div class="dropdown-menu dropdown-menu-right" aria-labelledby="nav-link-{$node->id}">
  73.                     {Nav_menu data=$node->children depth=$depth+1}
  74.                 </div>
  75.             {else}
  76.                 <a class="{$aclass}" href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}><span>{$node->menutext}</span></a>
  77.             {/if}
  78.             {if $depth < 1}</li>{/if}
  79.         {/if}
  80.     {/foreach}
  81. {/strip}{/function}
  82.  
  83. {if $default_navbar_style=="default"}<div class="container">{/if}
  84.     <nav class="{$navbar_classes}">
  85.         {if $default_navbar_style!=="default"}<div class="container">{/if}
  86.         {if $navbar_toggler_align=="right"}
  87.         <a class="navbar-brand" href="#">
  88.             {CGSmartImage src=$navbar_brand alias1=navbar_logo} {$navbar_brand_text}
  89.         </a>
  90.         {/if}
  91.  
  92.         <button class="navbar-toggler navbar-toggler-right"
  93.                 type="button"
  94.                 data-toggle="collapse"
  95.                 data-target="#navbarCollapse"
  96.                 aria-controls="navbarCollapse"
  97.                 aria-expanded="false"
  98.                 aria-label="Toggle navigation">
  99.             {fa i=bars}
  100.         </button>
  101.  
  102.         {if $navbar_toggler_align=="left"}
  103.         <a class="navbar-brand" href="#">
  104.             {CGSmartImage src=$navbar_brand alias1=navbar_logo} {$navbar_brand_text}
  105.         </a>
  106.         {/if}
  107.  
  108.         <div class="collapse navbar-collapse" id="navbarCollapse">
  109.             <ul class="navbar-nav ml-auto">
  110.                 {if isset($nodes)}
  111.                     {Nav_menu data=$nodes depth=0}
  112.                 {/if}
  113.             </ul>
  114.         </div>
  115.     {if $default_navbar_style!=="default"}</div>{/if}
  116.     </nav>
  117. {if $default_navbar_style=="default"}</div>{/if}
RAW Paste Data
Top