Hi,
I am building a portfolio section in my website for which I have this code in my project_item template:
The second part with [[!getImageList? is working ok, but have problem with the first part.
I can't h ave the [[+image]] and [[*pagetitle]] to be substituted with the actual data.
How can I reference for them outside of [[!getImageList? ?
Or is there a better way to do this? I am really not a developer.
Many thanks
<a href="[[+image]]" title="[[*content]]" rel="shadowbox[[[*pagetitle]]]">
<img src="[[+image]]" alt="[[*content]]" width="589" height="400" /></a>
[[!getImageList?
&tvname=`project_item`
&tpl=`@CODE:<a href="[[+image]]" class="structural" title="[[*pagetitle]]" rel="shadowbox[[[*pagetitle]]]" />[[*pagetitle]]</a>
`]]
[ed. note: openstep last edited this post 13 years, 10 months ago.]
do you really want to show the pagetitle of the current resource on each image?
-
☆ A M B ☆
- 24,524 Posts
When you use a standard resource field tag like [[*pagetitle]] or [[*content]] it will insert the value for the current resource (the page that is being looked at), not for the item that getImageList is processing. You need to use placeholder tags to match the fields in your MIGx form - [[+pagetitle]] and [[+content]].
I'm not sure to understand correctly what you are trying.
Lets say you have some resources with a working MIGX-TV in it, with some MIGX - images in each resource.
And you are listing this resources with getResources.
To get the first image into each output-block, you will need a getImageList-snippet-call in your getResources-tpl-chunk with something like that:
[[!getImageList?
&tvname=`project_item`
&tpl=`yourMIGXtpl`
&docid=`[[+id]]`
&limit=`1`
&pagetitle=`[[+pagetitle]]`
]]
chunk yourMIGXtpl:
<img src="[[+image]]" alt="[[+property.pagetitle]]" width="589" height="400" />
Thanks sottwell, I was thinking I need them just not sure exactly how. Would you show me how in my case, please?
I think for a newbie like me, someone who also more visual than a developer, a graphical explanation of this whole thing would be very useful. I am thinking something like infographics.
It is easy to get lost in all the details.
-
☆ A M B ☆
- 24,524 Posts
The visitor is looking at a page. This page is the "current resource". Remember this, it's important!
You have a listing snippet for this resource; getResources, Wayfinder, getImageList, it doesn't matter at all.
You have assigned the snippet some way to indicate what to loop through; &parents for getResources, &startId for Wayfinder, &tvname for getImageList.
The snippet gathers up all of the items where you told it to go look, and loops through them one at a time. It assigns the values for that item to placeholders; in the case of getImageList, it uses the input fieldnames in your TV's forms. Then it applies your tpl to the item, replacing the placeholder tags in the tpl with the values it saved. That is what the [[+placeholder]] tags in your tpl are for. It then goes on to do the same thing for the next item, and the next, for each item that it found where you told it to go look.
The snippet doesn't care at all about any other tags in the tpl. So if you have a standard MODx tag, like [[*pagetitle]], it ignores it, and MODx iteself will see that tag and replace it with the value for the current resource, just as it would for any resource that had that tag in it.
This is possible because MODx goes over the resource content several times. The first time, the snippet tags are there, and get processed, so the snippet does its looping through items and putting them into the tpl. Then MODx goes over the content again, and now instead of the snippet tags it has the listings that the snippet made, including any MODx tags in the tpl that the snippet didn't replace. MODx processes those tags as usual. So for every block in the listing, it will find the [[*pagetitle]] tag, and patiently replace each one with the pagetitle for the current resource.
you can have two different getImageList-calls
for the first image, you will use
for the other ones
or you can use an output-filter in the tpl:
[[+idx:is=`1`:then=`
here the html for the first image
`:else=`
here the html for all other images
`]]
does this do what you need?