Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Include components inside page
#3
This is what I'm using to manage and reuse components to be displayed outside the "page" wysiwyg editor. Sometimes some difference in the header, sidebar or other static area of the page is useful.

The i18n component is installed. For the sidebar it could be coded like this:

Code:
<div id="sidebar">
    <?php include('sidebar-social.inc.php'); ?>    // some static content

     <?php
        $page = (string) return_page_slug();
        // echo $page;  //uncomment to see the string for the active page
        if ($page == "index")  
            get_i18n_component('sidebar-custom-1');
        elseif ($page == "contact")
            get_i18n_component('sidebar-custom-1');
        elseif ($page == "testimonials")
            get_i18n_component('sidebar-custom-2');
        else
            get_i18n_component((string) return_page_slug()); // returns a component matching the name of the page
    ?>            

    <?php include('sidebar-portfolio.inc.php'); ?>  // some static content    
</div>


There is flexibility and simplicity ( thanks to GetSimple! ) and typing the php code for your needs is simple too. Your code needs to between "<?php" and "?>".

In the above code the sidebar-custom-1 component is used in the index and contact pages. And the sidebar-custom-2 component is used in the testimonials page. And if there is a component with the same name as the active page, it will display automatically via the code:

Code:
get_i18n_component((string) return_page_slug());

and, if none of the above criteria is met, then nothing is added to the sidebar.

I'm new to GetSimple, so please let me know if this flexibility is already handled elsewhere. I didn't find much about making custom code for individual pages and pieced this code from the excellent documentation for the i18n and other plugins. Thank you.
Reply


Messages In This Thread
Include components inside page - by amaurib - 2011-09-12, 08:04:08
Include components inside page - by mvlcek - 2011-09-12, 15:57:16
Include components inside page - by DonR - 2011-09-13, 05:17:16
Include components inside page - by mvlcek - 2011-09-13, 06:05:13



Users browsing this thread: 1 Guest(s)