Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Better Sidebar
#1
It would be much better if you could change the sidebar for each page - wihtout having to creat new functions of components.

Each sidebar could, in effect, be a seperate page that you just associate with the main page you want it to show on - if its not associated with a main page it doesnt show
Reply
#2
This can easily be achieved by creating sub pages for each page. Create the pages and make the parent the main page. Edit the page with the sidebar information you require.

Then put the following function in your themes functions.php

Code:
function get_content($page){  
        $thisfile = @file_get_contents(GSDATAPAGESPATH.$page.'.xml');
        $data = simplexml_load_string($thisfile);
        echo stripslashes(htmlspecialchars_decode($data->content, ENT_QUOTES));;
}

The on each page just call the function in the sidebar of the main page with the slug name of each subpage.

Mike.

edit: fixed up the code, thanks Carlos.. .
My Github Repos: Github
Website: DigiMute
Reply
#3
n00dles101 Wrote:Create the pages and make the parent the main page. Edit the page with the sidebar information you require.

Then put the following function in your themes functions.php

Code:
function get_content($page){  
        $thisfile = @file_get_contents(GSDATAPAGESPATH.$page.'.xml');
        $data = simplexml_load_string($thisfile);
        echo stripslashes(htmlspecialchars_decode($data->content, ENT_QUOTES));;
}

I'm not a coder but want to implement this idea. Let me see if I have this correct:

Say I have three pages Page1, Page2 and Page3 where I want to have context oriented sidebars. I will make three sidebar pages sb1, sb2 and sb3.
Is sb1 parent of Page1 or is Page1 parent of sb1?
How do I call the proper sidebar in Page1?

Then I'll add the code as shown to themes functions.php and it should work.
Thanks, Stew
Reply
#4
Maybe this would be easier for you to use: per page components. It will allow you to add code on a per page basis without having to program a system to do it.

If you want to use Mike’s approach you will need a little more code. The function he provides there only helps you to display the content of a different page. You will need to call that function as:
Code:
get_content('sidebarslug');
Of course, sidebarslug will have to be a different slug for all your pages so it gets a bit harder. A way to solve this is to create the pages page1, page2, page3 and the pages page1-sidebar, page2-sidebar, page3-sidebar. Then you can use Mike’s function as:
Code:
get_content(return_page_slug().'-sidebar');
The above code will use the current page’s slug and put “-sidebar” behind it to try and include a different sidebar on each page.

I would also like to put in the following function instead of the previous one. This gets rid of the @ sign and has slightly better performance because of that:
Code:
function get_content($page) {  
        if ($thisfile = file_get_contents(GSDATAPAGESPATH.$page.'.xml')) {
                $data = simplexml_load_string($thisfile);
                echo stripslashes(htmlspecialchars_decode($data->content, ENT_QUOTES));
        }
}
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#5
Child Menu could also accomplish this, by simply having your child pages be attached to your side bar, and then presenting your child data in sidebar and making all your content child content based.

Put this in your sidebar:
Quote:<?php go_child_menu(); ?>
Then simply reorganize your site data accordingly with the child data plugin.
Reply
#6
I am not a coder , does any one know the software for this? As like Thoosje sidebar !
Reply
#7
What would be really cool, is that if you could associate a icon with a child_menu() data so that you could have an icon->link and add a little bit more imagery to the base GS build.
Reply




Users browsing this thread: 1 Guest(s)