For every page on my site I have a folder in the MODx manager with articles. I'm using Ditto to collect the articles from a folder to generate the page content. The 开发者_开发技巧Ditto call is made from a page template. Now what I want is to use the same template for different pages with different articles from the corresponding folders. So the startid or parents parameter (the id of the parent folder of the articles) in the call has to be different for each page.
How do I set the startid or parents parameter in the Ditto call dynamically?
Are template variables the best way to go? And if so, how do I implement this? This must be a common issue, but I can't find a fitting answer on the internet.
Is each page actually the container for the articles that will be displayed on that page? If this is the case then you can just leave out the parents parameter and the current page will be used by default.
If the above isn't the case then you can use a template variable. You would create the template variable (ie. articleFolder) and use it as follows:
[!Ditto? &sortBy=`menuindex` &tpl=`homepage-news-item` &parents=`[+articleFolder+]` !]
精彩评论