Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inserting GS content on php page
#2
Pitching together some stuff from a different topic and code from the SVN I would add a function something like this:
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;
    }
}
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:
Code:
<?php get_content('slug'); ?>
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:
Code:
$variable = get_content('slug',false);
This will suppress the PHP echo.

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!
Reply


Messages In This Thread
Inserting GS content on php page - by dondemaio - 2010-11-27, 04:55:22
Inserting GS content on php page - by Zegnåt - 2010-11-27, 06:35:16
Inserting GS content on php page - by beat84 - 2011-04-09, 20:05:04
Inserting GS content on php page - by Connie - 2011-04-10, 01:03:10
Inserting GS content on php page - by beat84 - 2011-04-10, 17:58:35



Users browsing this thread: 1 Guest(s)