Hi ppl,
I have been trying to solve this one myself for a couple of days but no luck using Rev 2.6.1.
It's a onepager site for a car garage. There is a section that should show cars for sale.
There are different possible views for this section":
1. Subtitle "Occasions" and below "No cars for sale!"
2. Subtitle "Occasions" and below summary info for ex. "Tesla" "Model S" "125.000" on one line and below that another car.
3. Subtitle "Occasion" and below details + photos of the Tesla for example.
I am using getResources to retrieve the TV's for each car but having troubles showing 1,2,3!! I want to use the If snippet as this has helped me before but now i am stuck.
I have 1 template and think i need to use the If snippet to call getResources for each view.
So, 1 template. 2 documents: home and occasions. Occasions is a folder which holds a doc per car.
I hope someone can help me.
Maybe try something like this with a custom snippet
<?php
$value = $modx->resource->getTVValue('nameoftv');
if ($value == 'chunkA') {
$chunk = $chunkA;
} else{
$chunk = $chunkB;
}
return $modx->getChunk($chunk);
Call this on the page
[[!mySnippet? &chunkA=`occassionsTpl` &chunkB=`occassionsInfoTpl`]]
I assume that the photo is just a template variable which you can call into the second chunk but allow to be blank, no need for a third chunk?
I'm not totally clear on what you're trying to do, but you may not need any chunks.
How about something like this on the occasions page (or its template):
[[!getResources:ifempty=`No Cars for Sale`?&tpl=`myTpl`]]
or
[[!getResources:ifempty=`[[$NoCarsChunk]]`?&tpl=`myTpl`]]