Page 1 of 1
[SOLVED] Getting additional content-blocks from children
Posted: Wed Jan 13, 2010 3:35 pm
by sgtstevil
I'm working on a website for a booking-agency (dj's). I can entrust them with adding pages for a DJ, but I want the parent-page to show a list of dj's with their photos and a genre. These are content_blocks and content_image in the template for the Artistpage. I found some code which will list the children in an unordered list, with title and link:
Code: Select all
global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);
$nodes = $currentNode->getChildren();
if ($currentNode->hasChildren()) {
echo '<ul class="sectionlinks">';
foreach ($nodes as $node) {
$content= $node->getContent();
$url = $content->GetURL();
if ($url == "#") { /* section header has no link by default */
$url = "artists/".$content->Alias();
}
echo "<li><a href=\"".$url."\">".$content->MenuText()."</a> </li>";
}
echo "</ul>";
}
Can anyone explain how i'd get one of the other content_blocks? I've already assigned artist_pic to $artist_pic in the template
Re: [OPEN] How do I get other values from children?
Posted: Wed Jan 13, 2010 3:44 pm
by RonnyK
Check CGSimpleSmarty, that has some calls in its help to get the data of different blocks.
Ronny
Re: [OPEN] How do I get other values from children?
Posted: Thu Jan 14, 2010 2:56 pm
by sgtstevil
RonnyK wrote:
Check CGSimpleSmarty, that has some calls in its help to get the data of different blocks.
Ronny
Thanks! I'm not getting it to work however. I keep getting the error:
Fatal error: Call to a member function get_page_content() on a non-object in /usr/home/deb4806n5/domains/twig-bookings.com/public_html/lib/content.functions.php(771) : eval()'d code on line 13
The code looks like this atm:
Code: Select all
global $gCms;
$manager =& $gCms->GetHierarchyManager();
$thisPage = $gCms->variables['page_name'];
$currentNode = &$manager->sureGetNodeByAlias($thisPage);
$nodes = $currentNode->getChildren();
if ($currentNode->hasChildren()) {
echo '<ul class="sectionlinks">';
foreach ($nodes as $node) {
$content= $node->getContent();
$url = $content->GetURL();
$cgsimple->get_page_content($node,$artist_pic,$artist_picture)
if ($url == "#") { /* section header has no link by default */
$url = "artists/".$content->Alias();
}
echo "<li><a href="".$artist_picture."">".$content->MenuText()."</a> </li>";
}
echo "</ul>";
}
I think i'm taking a wrong approach here. Could someone set me off in the right direction?
Re: [still open :)] How do I get other values from children?
Posted: Thu Jan 28, 2010 8:53 pm
by sgtstevil
Am I in the wrong forum? Can someone gimme a hand please? I just need a kick in the right direction and then i'll dig the rest out myself...
Re: [still open :)] How do I get other values from children?
Posted: Wed Feb 10, 2010 6:33 pm
by sgtstevil
Seriously, this is quite a setback for me. I've found CMSMS to be the most useful CMS i've ever come across, but I just need a little bit of help to get started. I'd hoped to get the same kind of readiness to help as I did with silverstripe (which is a pig of a cms if you're not a real developer, but ppl on the forum are willing to answer even the noobiest of question), but I'm getting squat. Can anyone please explain why noone's helping me out here? Am I in the wrong forum? Is it too noob of a question to help me out? Wtf...
Re: [still open :)] How do I get other values from children?
Posted: Thu Feb 11, 2010 10:04 am
by tomgsd
I normally use a menu template to do this kind of thing. Something like this in a Menu Manager template (called "Sub-Section List"):
Code: Select all
{if $count > 1}
{foreach from=$nodelist item=node}
{* Get the picture *}
{$cgsimple->get_page_content($node->alias,'Overview_Picture_(for_list_page)','overview_pic')}
{* Get the overview text *}
{$cgsimple->get_page_content($node->alias,'Overview_Text_(for_list_page)','overview_text')}
{* Show them *}
<div class="picture">{$overview_pic}</div>
<div class="text">{$overview_text}</div>
{/foreach}
{/if}
This goes in the content of the "header" page or the template with the following:
Code: Select all
{menu template='Sub-Section List' start_page=$page_alias}
Then in the template for each sub page create your content blocks (remember that cmsms replaces spaces with underscores in your content block names - see above):
Code: Select all
{content_image block='Overview Picture (for list page)' dir='images/section_header_pics' urlonly='true'}
{content block='Overview Text (for list page)'}
A lot of problems can be solved in cmsms with smarty, there's often no need to bother with UDT's. I actually did this recently for DJ listings as well!
Re: [SOLVED] Getting additional content-blocks from children
Posted: Sat Feb 13, 2010 1:08 pm
by sgtstevil
Wow, that simple huh? Thanks a million!!!!! Now up and running on
www.elevation-events.com 
.