Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
get_page_content('pageID');
#1
Hi

I have project where I need multiple content on 1 page.
To keep this manageable, I would like to keep each part of content in a different page.
Designer wanted it to be a fancy 1 full jquery-animated page -_-

Now, is there a fast way or module to get page content by giving for example an extra parameter to the function in stead of the default by page slush.
Like: get_page_content('page2');

I don't feel like hacking the core though :/

Thanks guys!
Reply
#2
Hi,

You will be able to do this in 3.1 but as thats not released yet..
you can add the follwoing function to your themes functions.php

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

then just use get_content('pageslug');

hope it helps....

Mike.
My Github Repos: Github
Website: DigiMute
Reply
#3
n00dles, thanks for the reply.

It works like a charm and should be in core. Good to hear it's in the 3.1.
Reply
#4
yup will work for all versions.

version 3.1 will include the follwoing new functions.

http://get-simple.info/wiki/config:caching-function

Mike..
My Github Repos: Github
Website: DigiMute
Reply
#5
I once used Mike's funciton, but I had to modify it a bit, to see if user didn't delete accidentially one of essential pages, thus:
Code:
function load_page_content($id){
    $file = "data/pages/". $id .".xml";
    if ( file_exists($file) ){
        $data_index = getXML($file);        
        $page=stripslashes( html_entity_decode($data_index->content, ENT_QUOTES, 'UTF-8') );
    }else{
        $page="Page ".$id." doesn't exist";
    }
    
    return $page;
}
Addons: blue business theme, Online Visitors, Notepad
Reply
#6
glennb Wrote:Now, is there a fast way or module to get page content by giving for example an extra parameter to the function in stead of the default by page slush.
Like: get_page_content('page2');

If you use the I18N plugin, you can use get_i18n_content('page2') - it outputs the page and returns true if the page exists, false otherwise.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 1 Guest(s)