deutsch english
mvlcek online
software & more...
  • home
  • news
  • getsimple
    • i18n
    • navigation
    • gallery
    • search
    • news
    • rss feeds
    • custom fields
    • special pages
    • math/formulas
    • pagify
    • dynamic pages
    • hits & visits
    • faq
    • editor
    • theme settings
    • less/scss
    • how to...
      • ... sidebars
  • open source
  • faq
  • search
  • search (live)
  • rss
  • blog
  • sitemap
home » getsimple » how to... » ... sidebars

How to have different sidebars

If you want to have different sidebars on different pages, there are multiple ways to achieve this.

One way is to select a component based on the current page slug (and a default sidebar component if no page specific component exists), like

<?php
  if (return_i18n_component('sidebar-'.return_page_slug())) {
    get_i18n_component('sidebar-'.return_page_slug());
  } else {
    get_i18n_component('sidebar');
  }
?>

Just create a component sidebar-xxx for every page xxx that should not have the standard sidebar component sidebar.

Another way would be to to have a custom field (plugin I18N Custom Fields) named sidebar - preferably a dropdown field with all possible sidebar component names (or a text field, which is more error prone) - and include the selected sidebar component in the template:

<?php get_i18n_component(return_custom_field('sidebar')); ?>

or (with a fallback to the component sidebar)

<?php
  if (return_custom_field('sidebar')) {
    get_i18n_component(return_custom_field('sidebar'));
  } else {
    get_i18n_component('sidebar');
  }
?>

If the sidebar is different for every page, you can also create a custom WYSIWYG field sidebar and edit it on every page, then include it in the template:

<?php get_custom_field('sidebar'); ?>

or (with a fallback to the component sidebar)

<?php
  if (return_custom_field('sidebar')) {
    get_custom_field('sidebar');
  } else {
    get_i18n_component('sidebar');
  }
?>

 

© 2025 mvlcek online
Powered by GetSimple