GetSimple Support Forum

Full Version: dynpages, components and custom fileds not resolving my porblems
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
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).
the first method looks promising so i'll give a try later this night... i'll report any success/problem Smile thanks a lot and thanks for your great plugins!
Ok, i gave a quick try to the methods: the first didn't work couse there's a Typo on the test statament ( there's a ')' missing ). After that everything work perfect!

Brilliant! thanks for all your help!

I think this can be very useful for beginners like me having first approaches to getsimple and php... you could implement that in the examples or wiki of your plugin, really.

Anyway, mind the typo

cheers
Using a custom field (requires I18N Custom Fields plugin) is a better way to go about it as you get a WYSIWYG editor and the sidebar content is easier to find and edit in the backend. You can then fall back onto a default sidebar component if you wish.
Code:
<?php

if (return_custom_field('sidebar');) {
  get_custom_field('sidebar');
}
else {
  get_i18n_component('sidebar');
}

?>
j0lly Wrote:I think this can be very useful for beginners like me having first approaches to getsimple and php... you could implement that in the examples or wiki of your plugin, really.

Documented at http://mvlcek.bplaced.net/how-to/sidebars/.
mvlcek Wrote:
j0lly Wrote:I think this can be very useful for beginners like me having first approaches to getsimple and php... you could implement that in the examples or wiki of your plugin, really.

Documented at http://mvlcek.bplaced.net/how-to/sidebars/.

Well, perfect so!
thanks so much, now i have my personalized sidebars!