Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Inserting GS content on php page
#1
Hi. Can anyone tell me how to capture the text (content) inside a GetSimple page so another php page can display it? I'm looking for a <?php include statement that I can use.

Thanks in advance for any help you can give me.

Don
Reply
#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
#3
Hi, I need to get also the HTML assigned to that page.. how I can do it?

Thank you in advance.
Reply
#4
beat84 Wrote:Hi, I need to get also the HTML assigned to that page.. how I can do it?

Thank you in advance.


Beat, the pages are in XML format and they are stored in /data/pages

so any php script which deals with XML format can read that and do with the content what it wants (what you want)
but you cannot expect to get a complete solution for this here, but the net is full with tutorials for that

for example:

http://www.ibm.com/developerworks/library/os-xmldomphp/
|--

Das deutschsprachige GetSimple-(Unter-)Forum:   http://get-simple.info/forums/forumdisplay.php?fid=18
Reply
#5
I solved in this way:

Code:
echo file_get_contents($url)

I hope this can help.

Thanks
Reply




Users browsing this thread: 1 Guest(s)