Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Child and Parent pages...
#1
Is there a way to get the name of a child page and display it on the parent page? I would also like to get the date the child page was created/edited and displayed on the parent page. Anyways of doing this? I've tryed all the functions listed on the getsimple site but they didnt do what I was hoping for.

My page structure:

Code:
Index (parent)
- post-1 (child)
- post-2 (child)
- post-3 (child)

Thanks Smile
Reply
#2
you would have to make your own functions. like listed in another thread about showing multiple inputs on one page. for the date...

in your templates functions.php or admin/inc/theme_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));;
    }
    
    function get_content_date($page, $i = "l, F jS, Y - g:i A"){
        global $TIMEZONE;
        
        $path = "data/pages";
        $thisfile = @file_get_contents('data/pages/'.$page.'.xml');
        $data = simplexml_load_string($thisfile);
        if ($TIMEZONE != '') {
            if (function_exists('date_default_timezone_set')) {
                date_default_timezone_set($TIMEZONE);
            }
        }
        echo date($i, strtotime($data->date));
    }
http://nijikokun.com
random stuff. idk.
Reply
#3
Nijikokun Wrote:you would have to make your own functions. like listed in another thread about showing multiple inputs on one page. for the date...

in your templates functions.php or admin/inc/theme_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));;
    }
    
    function get_content_date($page, $i = "l, F jS, Y - g:i A"){
        global $TIMEZONE;
        
        $path = "data/pages";
        $thisfile = @file_get_contents('data/pages/'.$page.'.xml');
        $data = simplexml_load_string($thisfile);
        if ($TIMEZONE != '') {
            if (function_exists('date_default_timezone_set')) {
                date_default_timezone_set($TIMEZONE);
            }
        }
        echo date($i, strtotime($data->date));
    }


Hey, thanks for the reply Smile

I've added that to my functions.php file. What command in the template.php am I using to get the date of a child page?

Thanks.
Reply
#4
get_content_date('page-name','date format goes here google php date for more info');
http://nijikokun.com
random stuff. idk.
Reply
#5
hey, it dosen't quite work yet.

The code ive used to inset the date in the template.php file are these:

Code:
<?php get_content_date('post-1','d M Y'); ?>
<?php get_content_date('post-2','d M Y'); ?>
<?php get_content_date('post-1','d M Y'); ?>

The output from this is the same for all three: 01 Jan 1970

Confused not sure whats going on here...
Reply
#6
Anyone able to help? :/
Reply
#7
I'll check it out in a moment.
http://nijikokun.com
random stuff. idk.
Reply
#8
Nijikokun Wrote:I'll check it out in a moment.

hey, did you have any luck looking into it? Smile
Reply




Users browsing this thread: 2 Guest(s)