[TYPO3-english] Check if there is an image in the ressources of a page

Cédric Aellen cedric.aellen at gmail.com
Thu Mar 20 09:35:07 CET 2014


Here's the solution

```
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 = COA
            before.cObject.stdWrap.if.isTrue.field = media

            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
    }
}
```

Thanks to http://stackoverflow.com/a/22517904/498415


On 2014-03-19 19:36:11 +0000, Cédric Aellen said:

> 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 pages 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.
> 
> 
> ```html
> <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>
> ```
> 
> ![](http://cl.ly/image/3h281N2p3a0A/Napkin%2019.03.14%201.46.01%20PM.png)
> 
> ---
> 
> I have posted this question [on 
> Stackoverflow](http://stackoverflow.com/questions/22506231/check-if-there-is-an-image-in-the-ressources-of-a-page) 
> too




More information about the TYPO3-english mailing list