2010-11-27, 06:35:16
Pitching together some stuff from a different topic and code from the SVN I would add a function something like this:
Add this anywhere in your code (possibly in the theme’s functions.php file) and you can start including other pages by calling the function as:
Switch slug for the slug of the page you want to include.
As a little extra, if you want to put the content of the page in a PHP variable you can do the following:
This will suppress the PHP echo.
I hope this helps!
Code:
function get_content($page,$echo = true) {
if ($thisfile = file_get_contents(GSDATAPAGESPATH.$page.'.xml')) {
$data = simplexml_load_string($thisfile);
$content = stripslashes(htmlspecialchars_decode($data->content, ENT_QUOTES));
if ($echo) echo $content;
return $content;
}
}
Code:
<?php get_content('slug'); ?>
As a little extra, if you want to put the content of the page in a PHP variable you can do the following:
Code:
$variable = get_content('slug',false);
I hope this helps!
“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!
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!