Jump to content


Show Childeren.


  • You cannot reply to this topic
8 replies to this topic

#1 Jeroen

    Likes Etomite Forums!

  • Member
  • PipPip
  • 178 posts

Posted 28 August 2007 - 12:13 PM

Hy,

It's been a while since I worked with Etomite and I'm not sure I use all the functions right.

take a look at this snippet. It's suppossed to give a list of all the documents under the current page. But it doesn't do anything. I can't find out why.

I call this snippet like : [[ShowChild]]

// Snippet name: ShowChild
// Snippet description: Builds list of childeren documents of current document
// INPUT: id, sortHow, displayWhat, sortBy, 
// Revision: 1.00 ships with Etomite 0.6.1-Final


// no id set? get current document id
$id = isset($id) ? $id : $etomite->documentIdentifier;

// What field to display, default is pagetitle
$displayWhat = isset($displayWhat) ? $displayWhat : 'pagetitle';

// default sort is on menuindex ASC
$sortBy = isset($sortBy) ? $sortBy : 'menuindex';
$sortHow = isset($sortHow) ? $sortHow : 'ASC';

// select fields.
$fields = "id, pagetitle, description, longtitle, alias";

// END of config

$children = $etomite->getActiveChildren($id, $sortby, $sortdir, $fields);
$childrenCount = count($children);


if($children==false) {
    return false;
}

$menu = "";
$menu .= "<div class="showChild"><ul>";


for($x=0; $x<$childrenCount; $x++) {
  $menu .= "<li><a href='[~".$children[$x]['id']."~]'>".$children[$x][$displayWhat]."</a></li>";

}
$menu .= "</ul></div>";
return $menu;

can anybody help me out?

#2 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 28 August 2007 - 01:15 PM

Have you tried:

$children = $etomite->getActiveChildren($id, $sortBy, $sortHow, $fields);

Look at your code... You need to keep the same variables throughout, and keep them case-sensitive... I haven't tried it, but it should work...

#3 Jeroen

    Likes Etomite Forums!

  • Member
  • PipPip
  • 178 posts

Posted 29 August 2007 - 06:17 AM

Hy All,

Sorry I made a bit of a mess of things, but had the code as Ralph wrote it. But it doesn't work at all. I have no idea except that I'm using the wrong API functions or use them in the wrong way.

// Snippet name: ShowChild
// Snippet description: Builds list of childeren documents of current document
// INPUT: id, sortHow, displayWhat, sortBy, 
// Version 0.5 beta


// no id set? get current document id
$id = isset($id) ? $id : $etomite->documentIdentifier;

// What field to display, default is pagetitle
$displayWhat = isset($displayWhat) ? $displayWhat : 'pagetitle';

// default sort is on menuindex ASC
$sortBy = isset($sortBy) ? $sortBy : 'menuindex';
$sortHow = isset($sortHow) ? $sortHow : 'ASC';

// select fields.
$fields = "id, pagetitle, description, longtitle, alias";

// END of config

$children = $etomite->getActiveChildren($id, $sortBy, $sortHow, $fields);
$childrenCount = count($children);


if($children==false) {
    return false;
}

$menu = "";
$menu .= "<div class="showChild"><ul>";


for($x=0; $x<$childrenCount; $x++) {
  $menu .= "<li><a href='[~".$children[$x]['id']."~]'>".$children[$x][$displayWhat]."</a></li>";

}
$menu .= "</ul></div>";
return $menu;


#4 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 29 August 2007 - 06:50 AM

Unescaped quotes:

$menu .= "<div class="showChild"><ul>";
change to
$menu .= "<div class=\"showChild\"><ul>";

Your snippet works with this change. See here. It is possible that the error message saying unencaps whitespace in t string was hidden underneath your template if your template uses a div that is absolutely positioned to the top.
That's why I always use the AlexixProRedux template for snippet development (or any with a decent margin at the top of the page).

Edited by Cris D., 29 August 2007 - 06:55 AM.


#5 Jeroen

    Likes Etomite Forums!

  • Member
  • PipPip
  • 178 posts

Posted 29 August 2007 - 07:07 AM

Hy!

Great, now it works. I hate those silly mistakes....
I didn't got the error you mentioned. (I changed the template to be sure) Is that some php server-setting I should set in order to get more feedback from my installation?

#6 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 29 August 2007 - 07:29 AM

Quote

Parse error: syntax error, unexpected T_STRING in /yoursite/index.php(506) : eval()'d code on line 40
is generated by etomite. I don't know if this is effected by your server settings, but it is very odd that you did not get this error. What version of Etomite do you have?

#7 Jeroen

    Likes Etomite Forums!

  • Member
  • PipPip
  • 178 posts

Posted 29 August 2007 - 07:49 AM

Etomite Content Management System 0.6.1 Final (PL:4) (Prelude)

#8 Mukke

    Etomite Forum Newbie

  • Member
  • 47 posts

Posted 12 October 2007 - 10:15 AM

it is possible your host or webserver's php.ini has display_errors = Off
you can still turn them on with a .htaccess file

#9 Ralph

    Loves Etomite Forums!

  • Admin
  • 6,524 posts
  • Gender:Male

Posted 12 October 2007 - 01:14 PM

View PostMukke, on Oct 12 2007, 07:15 AM, said:

it is possible your host or webserver's php.ini has display_errors = Off
you can still turn them on with a .htaccess file
This is another feature that can be controlled within the php.ini file itself... Many settings flags can be toggled either through .htaccess or PHP's ini_set() function within a script...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users