Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dynpages, components and custom fileds not resolving my porblems
#2
j0lly Wrote:Hi, at first i want to say that Getsimple is really amazing, learing how to use it is really simple and i'm appreciating how easy it is!
I have encountered a little problem: i have a custom template with 2 variants (2 and 3 columns) to apply to my pages, and in the columns i'm using dynamic components like i18n menus and other php stuff. i need to set this components per-page but i don't want to have 20+ template to insert the components. i've tried custom fileds but seems not possible to pass php variables throw that (only text) neather using dynpages plugin to insert components.
So, how can i manage to edit the sidebars contents per-page without have to edit and greate a template for every page i want a differet component to attach?
i can't figure out this things but i'm sure you can point me to the right direction!
thanks

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
Code:
<?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 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:
Code:
<?php get_i18n_component(return_custom_field('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:
Code:
<?php get_custom_field('sidebar'); ?>

Edit: missing ) added in first code example (@j0lly).
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply


Messages In This Thread
dynpages, components and custom fileds not resolving my porblems - by mvlcek - 2012-08-13, 21:15:25



Users browsing this thread: 1 Guest(s)