Posts: 9
Threads: 3
Joined: Feb 2011
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!
Posts: 1,108
Threads: 70
Joined: Aug 2009
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.
Posts: 9
Threads: 3
Joined: Feb 2011
2011-10-15, 03:41:13
(This post was last modified: 2011-10-15, 03:51:24 by rtaustin.)
n00dles, thanks for the reply.
It works like a charm and should be in core. Good to hear it's in the 3.1.
Posts: 1,108
Threads: 70
Joined: Aug 2009
yup will work for all versions.
version 3.1 will include the follwoing new functions.
http://get-simple.info/wiki/config:caching-function
Mike..
Posts: 1,204
Threads: 30
Joined: Jun 2010
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
Posts: 2,094
Threads: 54
Joined: Jan 2011
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.