首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加数据-*属性以链接到html元素

添加数据-*属性以链接到html元素
EN

Stack Overflow用户
提问于 2019-08-08 12:02:49
回答 1查看 592关注 0票数 0

当尝试在类型链接上添加带有HTML元素的data-*属性时,解析htmlspecialchars中的某些内容将包含整个链接。

起初,我认为COA是问题所在(这似乎很奇怪,因为代码直到现在为止都起作用了),于是我转而使用文本元素,甚至撕毁了所有的包装,以便试图控制以何种方式呈现的内容,但没有任何用处。我也试图用FLUIDTEMPLATE替换它,但是它没有改变什么。

与COA

代码语言:javascript
复制
lib.contentElement.settings.media.popup.linkParams.ATagParams.postCObject = COA
lib.contentElement.settings.media.popup.linkParams.ATagParams.postCObject {

    10 = TEXT
    10 {
        field = uid
        noTrimWrap = | data-gallery="ce|" data-toggle="lightbox"|
    }
    20 = COA
    20 {
        stdWrap.noTrimWrap = | data-footer="|"|

        10 = TEXT
        10 {
            data = file:current:publicUrl
            wrap = <a class='downloadlink' href='|' target='_blank'>Download</a>
            if.isFalse.field = tx_emboss_lightbox_hidedownload
            if.isTrue.data = file:current:publicUrl
        }

        20 = TEXT
        20 {
            data = file:current:description
            wrap = <p class='caption'>|</p>
            if.isFalse.field = tx_emboss_lightbox_hidecaption
            if.isTrue.data = file:current:description
        }

        30 = TEXT
        30 {
            data = file:current:creator
            wrap = <p class='author'>|</p>
            if.isFalse.field = tx_emboss_lightbox_hideauthor
            if.isTrue.data = file:current:creator
        }
    }
    30 = TEXT
    30 {
        data = file:current:title
        noTrimWrap = | data-title="|"|
        if.isTrue >
        if.isTrue.data = file:current:title
        if.isFalse.field = tx_emboss_lightbox_hidetitle
    }
    40 = TEXT
    40 {
        value = true
        noTrimWrap = | data-showcount="|"|
        if.isFalse.field = tx_emboss_lightbox_hideimagecount
    }
}

无COA

代码语言:javascript
复制
lib.contentElement.settings.media.popup.linkParams.ATagParams.postCObject {

    10 = TEXT
    10 {
        field = uid
        noTrimWrap = | data-gallery="ce|" data-toggle="lightbox" |
    }

    11 = TEXT
    11.value = data-footer="

    12 = TEXT
    12 {
        data = file:current:publicUrl
        wrap = <a class='downloadlink' href='|' target='_blank'>Download</a>
        if.isFalse.field = tx_emboss_lightbox_hidedownload
        if.isTrue.data = file:current:publicUrl
    }

    13 = TEXT
    13 {
        data = file:current:description
        wrap = <p class='caption'>|</p>
        if.isFalse.field = tx_emboss_lightbox_hidecaption
        if.isTrue.data = file:current:description
    }

    14 = TEXT
    14 {
        data = file:current:creator
        wrap = <p class='author'>|</p>
        if.isFalse.field = tx_emboss_lightbox_hideauthor
        if.isTrue.data = file:current:creator
    }

    15 = TEXT
    15.value = "

    30 = TEXT
    30 {
        data = file:current:title
        noTrimWrap = | data-title="|"|
        if.isTrue >
        if.isTrue.data = file:current:title
        if.isFalse.field = tx_emboss_lightbox_hidetitle
    }
    40 = TEXT
    40 {
        value = true
        noTrimWrap = | data-showcount="|"|
        if.isFalse.field = tx_emboss_lightbox_hideimagecount
    }
}

与FLUIDTEMPLATE

代码语言:javascript
复制
lib.contentElement.settings.media.popup.linkParams.ATagParams.postCObject = FLUIDTEMPLATE
lib.contentElement.settings.media.popup.linkParams.ATagParams.postCObject {
    file = EXT:emboss_lightbox/Resources/Private/Standalone/GalleryImage.html
    dataProcessing.10 = TYPO3\CMS\Frontend\DataProcessing\FilesProcessor
    dataProcessing.10 {
        # the field name where relations are set
        # + stdWrap
        files.data = file:current:uid

        # The target variable to be handed to the ContentObject again, can be used
        # in Fluid e.g. to iterate over the objects. defaults to "files" when not defined
        # + stdWrap
        as = images
    }
}

流体

代码语言:javascript
复制
<f:spaceless>data-gallery="ce{field:uid}" data-toggle="lightbox" data-footer="<f:if condition="{data.tx_emboss_lightbox_hidedownload} != true"><f:if condition="{images.0.publicUrl}"><a href='{images.0.publicUrl}' target='_blank'>Download</a></f:if></f:if><f:if condition="{data.tx_emboss_lightbox_hidecaption} != true"><f:if condition="{images.0.description}"><p class='caption'>{images.0.description}</p></f:if></f:if><f:if condition="{data.tx_emboss_lightbox_hideauthor} != true"><f:if condition="{images.0.creator}"><p class='author'>{images.0.creator}</p></f:if></f:if>" data-title="{images.0.title}" data-showcount="true"</f:spaceless>

Fluid(readable)这个版本让我很不爽,因为我所有的新行都变成了<p>&nbps;</p>

代码语言:javascript
复制
    <f:spaceless>
        data-gallery="ce{field:uid}" data-toggle="lightbox" data-footer="
        <f:if condition="{data.tx_emboss_lightbox_hidedownload} != true">
            <f:if condition="{images.0.publicUrl}">
                <a href='{images.0.publicUrl}' target='_blank'>Download</a>
            </f:if>
        </f:if>
        <f:if condition="{data.tx_emboss_lightbox_hidecaption} != true">
            <f:if condition="{images.0.description}">
                <p class='caption'>{images.0.description}</p>
            </f:if>
        </f:if>
        <f:if condition="{data.tx_emboss_lightbox_hideauthor} != true">
            <f:if condition="{images.0.creator}">
                <p class='author'>{images.0.creator}</p>
            </f:if>
        </f:if>" data-title="{images.0.title}" data-showcount="true"</f:spaceless>

预期的输出如下所示:

代码语言:javascript
复制
    <a href="link to image" title="image title" data-gallery="cexyz" data-toggle="lightbox" data-footer="<a href='path to publicUrl'>Download</a><p class='caption'>Some description with possible html in it too</p><p class='author'>Some author</p>" data-title="image title" data-showcount="true"><img src="Someimage.jpg"></a>

相反,我得到了这个:

代码语言:javascript
复制
    &lt;a href=&quot;link to image&quot; title=&quot;image title&quot; data-gallery=&quot;cexyz&quot; data-toggle=&quot;lightbox&quot; data-footer=&quot;&lt;a href='path to publicUrl'&gt;Download&lt;/a&gt;&lt;p class='caption'&gt;Some description with possible html in it too&lt;/p&gt;&lt;p class='author'&gt;Some author&lt;/p&gt;&quot; data-title=&quot;image title&quot; data-showcount=&quot;true&quot;&gt;<img src="Someimage.jpg">&lt;/a&gt;
EN

回答 1

Stack Overflow用户

发布于 2019-08-09 05:19:52

正如您在结尾所显示的,您的问题不是数据属性,而是整个链接。该部分没有包含您的代码。我想你只需要一个<f:format.raw>标签围绕你的链接。

也许连整个CE都受到了影响,而且您还没有注意到,因为文本中没有其他特殊字符。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57412152

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档