Topic: Get children page content?

Hi,

I need a bit of help/advice on this.  I want to display the content of  sub-page on the home page
For example; I have main page Services with 4 sub-pages, each sub-page will have some text.

I have  managed to show the list of the childpage using this code

<?php $pages = Page::children('page'); ?>
<?php foreach($pages as $page) { ?>
<a href="<?php echo Site::url().'about/'.$page['slug']; ?>"><?php echo $page['title']; ?></a>
<?php } ?>

But I dont know how to get the content of the sub-page as well.  Can someone give me some advice on this?

Thank you!

2 2015-04-08 08:48:43

Re: Get children page content?

@andreid

Try this:

<?php echo Page::get('your page'); ?>

wink

http://monstracreative.com - themes, plugins and snippets for monstra cms

:: ATTENTION ::
Need help? Login at your account at: http://monstracreative.com/users/login. -> You have a excellent support center at our website! wink

wormsunited's Website

3 (edited by andreid 2015-04-08 19:56:55)

Re: Get children page content?

Thank you for the reply.

That code doesnt work for me. Probably i dont use it as i should  I dont know much php.
What i want to achive is this
http://i59.tinypic.com/15ppu74.png.
I cant find how to get the conetnt of each subpage. Managed to get the titles though.

Re: Get children page content?

@andreid

Ho that is simple... Do this:

1 - create a template for that page
2 - Add the code you have on top, as i see its a List so you must place your <li> tags on it.

Here is a example:

<?php $pages = Page::children('your section'); ?>
<?php foreach($pages as $page) { ?>
<li><a href="<?php echo Site::url().'/your section/'.$page['slug']; ?>" class="If you want to call a class"><?php echo $page['title']; ?></a></li>
<?php } ?>

This should work for you pretty fine! wink

http://monstracreative.com - themes, plugins and snippets for monstra cms

:: ATTENTION ::
Need help? Login at your account at: http://monstracreative.com/users/login. -> You have a excellent support center at our website! wink

wormsunited's Website

5 2015-04-19 08:23:10

Re: Get children page content?

Hi,
Sorry for not getting back in a while.
That is the same thing I did. I managed to get the Sub-pages title.Each sub-page has  a bit of content .  How do I get the sub-pages content?
Thanks!

6 2015-04-20 09:01:02

Re: Get children page content?

@andreid,

Use this:

<?php echo Site::content('your content'); ?>
http://monstracreative.com - themes, plugins and snippets for monstra cms

:: ATTENTION ::
Need help? Login at your account at: http://monstracreative.com/users/login. -> You have a excellent support center at our website! wink

wormsunited's Website

Re: Get children page content?

@andreid,

Just faced the same problem and found solution:

making new template, making new page assigning that template to page, in template adding this code for each page we want to show content inside our 1 page, u can even make 1 page themes with it

<?php echo Page::content('YOUR PAGE SLUG NOt name but slug'); ?>

Example of mine i show 6 pages inside page Details:

<?php echo Page::content('payment'); ?>
<?php echo Page::content('delivery'); ?>
<?php echo Page::content('refund'); ?>
<?php echo Page::content('how-to-order'); ?>
<?php echo Page::content('terms-conditions'); ?>
(с) Roman Art
So far So good wink

RomanArt's Website