kreativan
9/9/2018 - 2:20 PM

processwire language switcher

processwire language switcher

<?php
/**
 * Languages
 * 
 */
 
 foreach($languages as $language) {
    echo $language->title;
 }
 
?>

<?php
/**
 *	Basic
 * 
 */
?>
<?php foreach($languages as $language) : ?>
    <?php if($user->language->id == $language->id) :?>
        <span class="active"><?=$language->title?></span>
    <?php else : ?>
         <a href="<?=$page->localUrl($language)?>"><?=$language->title?></a>
     <?php endif;?>
<?php endforeach;?>

<?php
/**
 * UIkit Dropdown
 * 
 */
?>

<li class="tm-lang-switcher">
  <a href="#"><span><?= $user->language->title ?></span></a>
  <?php if(count($languages) > 1) :?>
    <div class="uk-navbar-dropdown">
      <ul class="uk-nav uk-navbar-dropdown-nav">
        <?php foreach($languages as $language) : ?>
          <?php if($user->language->id == $language->id) :?>
            <li class="uk-active"><span><?= $language->title ?></span><li>
          <?php else : ?>
            <li><a href="<?= $page->localUrl($language) ?>"><?= $language->title ?></a></li>
          <?php endif;?>
        <?php endforeach;?>
      </ul>
    </div>
  <?php endif;?>
</li>