Just to ensure there is no misunderstanding:
What I understand is you have a main page (parent - level 1) that pulls in content from other pages (child pages - level 2) - similar to a blog overview page, where it shows excerpts of its child pages content.
I presume your main page (parent) has the following in it:
[[Ditto? &parents=`[*parent*]` &id=`portfolio-content` &depth=`1` &tpl=`portfolio-content`]]
What I don't understand here is the:
I don't think that works - I may be wrong. I was under the impression that the following is used as it designates (in this situation) its own ID:
Side tracked there, sorry
If you are calling "[+content+]" in your "portfolio-content" template you
will always output all of the contents of the main content box / area of that page.
If you only want a part of the content you need to cut the amount of characters down and you will need to strip the HTML tags as well.
You can use Ditto's built in PHX functions to do that:
Create 2 new snippets:
phx:striptags
<?php
return($modx->stripTags($output, $options));
?>
phx:word_limit
<?php
$retval = $output;
$array = explode(" ", $output);
if (count($array)<=$options)
{
$retval = $output;
}
else
{
array_splice($array,$options);
$retval = implode(" ", $array);
}
return $retval;
?>
This is just a guess, so if it's wrong you will have to modify as required:
In your "portfolio-content" template, change "[+content+]" to this:
[+content:word_limit=`50`:striptags+]
The new call delimits the snippets using ":" therefor both snippet calls are added in one.
[ed. note: iusemodx last edited this post 10 years, 1 month ago.]