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));
}
}