如何在typo3中使用div包装图像? [英] How to wrap image with div in typo3?

查看:91
本文介绍了如何在typo3中使用div包装图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要删除默认的环绕图像,我使用了以下模板代码:

To remove default wrap around image, i have used this template code:

tt_content.image.20.rendering.noWraps {
  imageRowStdWrap.dataWrap = |
  noRowsStdWrap.wrap = |
  oneImageStdWrap.dataWrap = |
  imgTagStdWrap.wrap = |
  editIconsStdWrap.wrap = |
  caption.wrap = |
}
# Set this as active rendering method
tt_content.image.20.renderMethod = noWraps

我想在特定部分的代码上方覆盖它.

I want to override it above codes for a specific section.

这是我的代码:

SCREENSHOTS<styles.content.get
SCREENSHOTS.select.where = colPos = 9
SCREENSHOTS.renderObj.dataWrap = <div class="screen">|</div>

它不起作用.怎么做?

推荐答案

根据

由于在上面的示例中未显式设置.renderObj,因此TYPO3将自动设置1.renderObj< tt_content ,以便renderObj将引用 tt_content 的TypoScript配置.相应的TypoScript配置将被复制到renderObj.

Since in the above example .renderObj is not set explicitly, TYPO3 will automatically set 1.renderObj < tt_content, so that renderObj will reference the TypoScript configuration of tt_content. The according TypoScript configuration will be copied to renderObj.

由于您声明了SCREENSHOTS.renderObj.dataWrap = <div class="screen">|</div>,因此您不会正确地将任何配置自动复制到您的renderObj.

Since you declare SCREENSHOTS.renderObj.dataWrap = <div class="screen">|</div> you properly wont have any configuration automatically copied to your renderObj.

如果我理解您的目标正确,那么您希望删除所有围绕仅图像"内容元素的包装,并将其全部包装在一个div标签<div class="screen">|</div>中.以下内容未经测试,但如果您提供的第一个阻止的代码适用于所有仅图像"内容元素,则应该可以使用.

If I understand your goal correct then you wish to remove all wraps around 'image only' content element and wrap it all in one div tag <div class="screen">|</div>. The following is untested but should work if your provided first code blocked worked for all your 'image only' content elements.

# Create a new renderMethod named 'noWraps' which can be used across the whole system
tt_content.image.20.rendering.noWraps {
  imageRowStdWrap.dataWrap = |
  noRowsStdWrap.wrap = |
  oneImageStdWrap.dataWrap = |
  imgTagStdWrap.wrap = |
  editIconsStdWrap.wrap = |
  caption.wrap = |
}

SCREENSHOTS < styles.content.get
SCREENSHOTS {
  select.where = colPos = 9
  renderObj < tt_content
  renderObj {
    # Set renderMethod to 'noWraps' only for this section
    image.20.renderMethod = noWraps

    # Change the default wrapping around the content element but only if it's a 'image only' contant element
    stdWrap.innerWrap >
    stdWrap.innerWrap.cObject = CASE
    stdWrap.innerWrap.cObject {
      key.field = CType
      default < tt_content.stdWrap.innerWrap.cObject
      image = TEXT
      image.value = <div class="screen">|</div>
    }
  }
}

如果上面的代码不起作用,那么只需写一个注释,然后我将对其进行研究.

If the above code dose not work then just write a comment and then I will take a look into it.

这篇关于如何在typo3中使用div包装图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆