Instead of directly use
before.cObject = IMAGE
use a COA:
before.cObject = COA
before.cObject {
stdWrap.if {
isTrue.field = media
}
10 = IMAGE
10 ...
}
and you so put the "if.isTrue" on the COA
Question
I've got a serie of page and shortcut in a sysfolder. With those page, I build a list of links.
You can add an image for each links by adding an image in the ressources in the page properties.
Everythings work perfectly except for page without image. If so, the links, is show twice.
I need to add a condition to not execute the before.cObject
things if there no image in the ressources.
This is were I need your help.
lib.menu = HMENU
lib.menu {
special = directory
special.value = {$lib.sysfolder}
wrap = <ul>|</ul>
1 = TMENU
1 {
NO {
allWrap = <li>|</li>
ATagTitle.field = subtitle // title
before.cObject = IMAGE
before.cObject.file.import = uploads/media/
before.cObject.file.import.field = media
before.cObject.file.import.listNum = 0
before.cObject.altText.field = abstract
before.cObject.stdWrap.typolink.parameter.field = uid
}
ACT = 0
}
}
Here's an example of the generated HTML. It's a liste with three items. The first and third one havn't got any image. The second got one.
<ul>
<li>
<a href="mobile/">Mobile</a><a href="mobile/" title="Mobile" onfocus="blurLink(this);">Mobile</a>
</li>
<li>
<a href="actualite/flux-rss-et-reseaux-sociaux/"><img src="uploads/media/feed.png" width="16" height="16" border="0" alt="Icône de flux RSS"></a><a href="actualite/flux-rss-et-reseaux-sociaux/" title="RSS" onfocus="blurLink(this);">RSS</a>
</li>
<li>
<a href="contact/">Contact</a><a href="contact/" title="Contact" onfocus="blurLink(this);">Contact</a>
</li>
</ul>
Solution
Instead of directly use
before.cObject = IMAGE
use a COA:
before.cObject = COA
before.cObject {
stdWrap.if {
isTrue.field = media
}
10 = IMAGE
10 ...
}
and you so put the "if.isTrue" on the COA