Question

Very simply I want to have multiple content regions on a single page. Note this is my first Modx site.

So far I have the home page and created child documents for the sub regions on the home page. All I want is to call them in the template.

For example there is a document with an id of 2, and I want the long title on the home page (id of 1).

Something like :

[[~2*longtitle]] 

Unfortunately the above just returns the url to that sub document and not the longtitle of that document itself.

So far I've found no documentation on doing so. Does anyone know how to accomplish this?

Was it helpful?

Solution

You have 2 options, the hard way ~ the route you have chosen ;) and the easy way... which I will outline as well.

For what you are trying to do you are going to want to use either getResources http://rtfm.modx.com/display/ADDON/getResources which will allow you to loop over a collection of resources & extract the fields you need [in this case 'content'] or getresourceField http://rtfm.modx.com/display/ADDON/getResourceField which will allow you to specify a single resource & the field to extract, just call it multiple times in your template.

You might try:

[[getResources? &parents='[[*id]]' &tpl='myTpl' &includeContent='1']] 

Should get all the child resources [up to default ~ 10] of the current resource, then you would create a template for get resources to loop over:

<h1>[[+longtitle]]</h1>
<p>[[+content]]</p>

notice the use of + instead of * for the resource fields

OR

the easy way, create template variables for your extra content areas, you can set them up as rich text areas as well. that way all your content for any given page is within the one resource ~ no need for you to create child resources to hold content for your header/footer/sidebar/etc

Either way will work, the TV method may use less overhead though.

OTHER TIPS

you can use fastfield

[[#12.pagetitle]]

or in a call

[[#[[+id]].pagetitle]]

You can also grab all TVs of that resource, like

[[#12.myTv]]

see also: http://rtfm.modx.com/extras/revo/fastfield

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top