typo3中img-tag中的alt / title属性

时间:2014-09-23 20:06:39

标签: typo3 typoscript

我使用以下Typoscript获取包含来自相应页面资源的图像的页面菜单。 如何获取图片alt和/或标题标签的页面标题(或页面描述等)?

tt_content.menu.20.4 >
tt_content.menu.20.4 = COA
tt_content.menu.20.4 {
    wrap = <div>|</div>
    10 = HMENU
    10 {
        special = directory
        special.value.field = pages
        1 = TMENU
        1 {
            noBlur = 1
            NO = 1
            NO {
                stdWrap >
                stdWrap {
                    cObject = COA
                    cObject {
                        10 = FILES
                        10 {
                            references {
                                table = pages
                                uid.data = field = uid
                                fieldName = media
                                data = levelmedia:-1, slide
                                treatIdAsReference = 1
                                listNum = 0
                            }
                            renderObj = IMG_RESOURCE
                            renderObj {
                                file.import.data = file:current:publicUrl
                                file.maxW = 100
                                file.maxH = 60
                                required = 1
                            }
                        stdWrap.wrap = <img src="|" title="???pagetitle???" alt="???pagetitle???">
                        }
                    }
                }
                wrapItemAndSub = <div>|</div>
            }
        }
    }
}

2 个答案:

答案 0 :(得分:0)

您是否尝试过使用dataWrap?

我认为它可能是这样的

stdWrap.dataWrap = <img src="|" title="{field:title}" alt="{field:title}">

或者也许......

stdWrap.dataWrap = <img src="|" title="{page:title}" alt="{page:title}">

答案 1 :(得分:0)

现在对我有用

cObject = COA
cObject {
 10 = FILES
 10 {
  references {
    table = pages
    uid.data = field = uid
    fieldName = media
    data = levelmedia:-1, slide
    treatIdAsReference = 1
    listNum = 0
  }
  renderObj = COA
  renderObj {
   10 = IMG_RESOURCE
   10.stdWrap.wrap = <img src="|
   10.file.import.data = file:current:publicUrl

   20 = TEXT
   20.stdWrap.wrap = " title="|
   20.data = file:current:title

   30 = TEXT
   30.stdWrap.wrap = " alt="|" />
   30.data = file:current:title
  }
  stdWrap.wrap = |
  stdWrap.required = 1
 }
}