Tip: Easily display the content of all sub-pages (child pages)

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am
Location: Deatsville, AL

Tip: Easily display the content of all sub-pages (child pages)

Post by Elijah Lofgren »

If you want to display the content of all child pages of the current page:
1. Download and install the CGSimpleSmarty module
2. Put this in your template:

Code: Select all

<h2>Child page content (experimental)</h2>
<h2>Child page content (experimental)</h2>
{foreach from=$cgsimple->get_children('','',$children) item='child'}
    {if $child.show_in_menu}
        <h3><a href="/{$child.alias}/">{$cgsimple->get_page_title($child.alias)}</a></h3>
        {$cgsimple->get_page_content($child.alias)}
    {/if}
{/foreach}
Thank you VERY MUCH to calguy1000 for helping me with this! :) :D ;D
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
cnymike
Power Poster
Power Poster
Posts: 446
Joined: Sun Jan 22, 2006 3:24 am

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by cnymike »

That is an extremely helpful bit of code. Thank you for sharing!

Michael
timmahoney
New Member
New Member
Posts: 9
Joined: Wed Jul 09, 2008 2:28 pm

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by timmahoney »

Booya - Great bit of code there - Thanks!
denli
Forum Members
Forum Members
Posts: 86
Joined: Tue Sep 04, 2007 12:26 pm

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by denli »

Hi all,

Sorry but I dont see how this would replace the pageblock module?
Am I overlooking something here?

Id like it very very much if somebody could explain to me how I can make pageblocks with this and how I can convert my old pageblocks to this new type of blocks it would be great!

Dejo

[edit]

Got it going its actually pretty easy ones u take a good look  ;)

I think that it would be very useful if there was a Tutorial of this because I could understand that some would not know what to do.

Thanks Elijah very useful bit of code!
Last edited by denli on Wed Jul 16, 2008 10:44 am, edited 1 time in total.
denli
Forum Members
Forum Members
Posts: 86
Joined: Tue Sep 04, 2007 12:26 pm

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by denli »

Hi Again!  ;D

I am almost there!

I got one question:
How do I get extra content blocks out of a child page?  :-\

I got a content block for images, and table data but I only succeed in importing the child Title and content.
I tried every ting I could think of but it just wont work!

I hope someone knows how to do this!
applejack
Power Poster
Power Poster
Posts: 1014
Joined: Fri Mar 30, 2007 2:28 am
Location: London

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by applejack »


Website Design & Production
http://www.applejack.co.uk
streever

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by streever »

MAybe I am just tired, but can someone plz explain this to me? I tried to understand it several times :-/. It seems like it just pulls child pages?

but what if I have real child pages.... but I want page blocks....? :(? Does this really do the same function as page blocks?
streever

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by streever »

OK, so I am awake now, and still don't get it.

I need a system that lets my end-user easily add blocks of content to a page. This just seems to agregate the child pages, is that correct?

I have top-level pages that have child pages that ALSO have content blocks. (What I used to call page blocks)

Basically, it's a simple 3 column layout. Column 1==navigation. Column 2 == content. Column 3 == little blocks of content that the client adds on as needed.

With pageblocks, they just clicked, "Add a block" and did. It was super easy! Everyone loved it. I had each content block in it's own div, so that it created a little border at the bottom! Bellisimo!

But now there seems no way to do this?

Do have to downgrade my CMS install to an older one?

I already have this job & am coding it :( Didn't realize that page blocks would be removed... :(!

I miss you page blocks. *pours out a 40*
streever

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by streever »

I posted a response, or tried to!

yea, it works. sorry all.
jubasolo
Forum Members
Forum Members
Posts: 19
Joined: Wed Aug 13, 2008 3:09 pm

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by jubasolo »

Hi, there

Mark or Streever (or both): Could you please explain how you got the Page Blocks to work? I have the same problem with the "Add Block" link not showing up. Is there anything I can do to make it work like in the version Savaii ??

Jonathan
denli
Forum Members
Forum Members
Posts: 86
Joined: Tue Sep 04, 2007 12:26 pm

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by denli »

jubasolo wrote: Hi, there

Mark or Streever (or both): Could you please explain how you got the Page Blocks to work? I have the same problem with the "Add Block" link not showing up. Is there anything I can do to make it work like in the version Savaii ??

Jonathan
Jonathan,

This is not about solving the pageblock problem. The pageblocks are no longer supported so this is about a new way of making a new cind of pageblocks, better if you ask me!.

Ill try to explain please don't bite me if you already know or if my English is not zo good.

First thing I did is copy my default template and ad this:

Code: Select all

<div style="float: right;">{print showbutton=true script=true}</div>
<div class="lijn"></div>
<table class="info-blok">
<tr >
<td class="title-blok" colspan=2 ><h1 class="front-h4">{content block="titel" oneline="true"} (u kunt deze pagina gebruiken voor printen of info aan te vragen.</h4></td></tr>
<tr >
<td class="afbeelding-blok">{content block="afbeelding"}</td> 
<td class="omschrijving">{content block="omschrijving"}</td></tr>
<tr>
<td class="afbeelding-blok"></td>
<td class="data">{content block="data"}</td>
</tr>
<tr>
<td  colspan="2" class="offerte-knop">Offerte/info aanvragen over {title}:</br>{cms_module module='FormBuilder' form='pat-contact'}</td></tr> 
</table>
Under {content} I use the divs and tables becouse the child that I use to take the info out of is also visible.
Wy well now I can display only the wanted product instead of a collection of children. This single product page can be used to print or ask for info.

If you dont use the child (pageblock) to show then this:
{content block="titel" oneline="true"}
{content block="afbeelding"}
{content block="omschrijving"}
{content block="data"}

Is more then you will need.(this way you use the child like pageblocks)
I call the above mentioned template Input-content or you could call it "pageblock".

Then I make a second template which is the product page in my situation this page collects al the children beneath.
I call this Template "product-page". This is actually the template u use for the pages that you want to show their children wich use the template "input-content".

Code: Select all

{foreach from=$cgsimple->get_children('','',$children) item='child'}
    {if $child}
<div class="lijn"></div>
<table class="info-blok">
<tr >
<td class="title-blok" colspan=2 ><h1 class="front-h4">{$cgsimple->get_page_content($child.alias,'titel')}</h4></td></tr>
<tr >
<td class="afbeelding-blok">{$cgsimple->get_page_content($child.alias,'afbeelding')}</td> 
<td class="omschrijving">{$cgsimple->get_page_content($child.alias,'omschrijving')}</td></tr>
<tr>
<td class="afbeelding-blok"></td>
<td class="data">{$cgsimple->get_page_content($child.alias,'data')} </td>
</tr>
</table>
</br>
    {/if}
{/foreach}


So now when you want a page block in this new setup you just ad a new page in your admin/pages
You gif this page the template "input-content" you place this page under the page you want to get the info into.
Next go to the page (parent of that child) that needs to collect this info and gif this the template "product-page" (the name in my situation).

Now it should work, you can put as many pages (pageblocks) under the page with template "product-page" as you want like you used to with the old pageblocks.

That's all I did to make it work for me! remember you need CGSimpleSmarty module
for this to work.

I like this contribution because you can ad edit the new pageblocks on the same page as where you ad edit your pages.

I hope this was helpful for you?
jubasolo
Forum Members
Forum Members
Posts: 19
Joined: Wed Aug 13, 2008 3:09 pm

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by jubasolo »

Thanks for your help and your most wonderful explanation.

I somehow got the Page Blocks to work, but only in English. So I did not try your suggestions. I forgot to answer your reply, which I am sorry for. Thanks for your time.

Today I discovered a reply which explains the solution to my original problem though. So to all friends of Page Blocks, please look at this thread, and your problems with language in Page Blocks are gone:

http://forum.cmsmadesimple.org/index.php?topic=24627


Jonathan
m e l

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by m e l »

really nice, works fine here. is it possible to display child pages depending on their template? i couldnt figure out which object i can access to retrieve information about the childs template-id or name.
naturelab
Forum Members
Forum Members
Posts: 169
Joined: Thu Oct 15, 2009 11:11 am

Re: Tip: Easily display the content of all sub-pages (child pages)

Post by naturelab »

Code: Select all

<dl>
<dt>{$cgsimple->get_page_title($child.alias)}</dt>
<dd>{$cgsimple->get_page_content($child.alias, 'pullout')}</dd>
 <dd><a href="/{$child.alias}/" title="{$cgsimple->get_page_title($child.alias)}">Learn more »</a></dd>
</dl>
... where 'pullout' is the name of the content block to grab text from.

Hi - I've been using this successfully, but now I want to grab an image from a child page, but can't seem to get it to work - any ideas ?

This is what I have on each page :-

Code: Select all

{capture assign='page_image'}{content_image block='Page Image' dir='images/Gallery/gallery1' urlonly='true'}{/capture}
So I need to replace 'pullout', with the name of a content block that contains the image -'Page Image'

Code: Select all

<dl>
<dt>{$cgsimple->get_page_title($child.alias)}</dt>
<dd>{$cgsimple->get_page_content($child.alias, 'Page Image')}</dd>
 <dd><a href="/{$child.alias}/" title="{$cgsimple->get_page_title($child.alias)}">Learn more »</a></dd>
</dl>
I can't seem to return any reference to this content block at all.

Any help greatly appreciated.

All the best
Post Reply

Return to “Tips and Tricks”