整个COA的typolink

时间:2016-03-23 16:15:22

标签: typo3 typoscript typo3-6.2.x

我正在尝试在我的所有内容对象周围设置一个链接,因此整个内容都被包装。到目前为止,我尝试过这样的事情:

#Rendering start box text with image
ap_content.textpic.100  = COA
ap_content.textpic.100{
    wrap = <div class="start-box-wrapper link">|</div>
    10 = FILES
    10{               
        references{
            table = tt_content
            uid.field = uid
            fieldName = image
        }            
        renderObj = COA
        renderObj{
            wrap = <img class="lazy img-responsive" src="fileadmin/{$folderName}/Resources/Public/Images/loading-spin.svg"|/>

            11 = IMG_RESOURCE
            11{
                stdWrap.noTrimWrap = | data-src="|"|
                file{
                    import.data = file:current:originalUid // file:current:uid
                    maxW{
                        if.isTrue.field = tx_t3webkit_retina
                        cObject = USER
                        cObject {
                            userFunc = usr_t3webkitHelpers->getImageDimensions
                            userFunc{
                                picture = IMG_RESOURCE
                                picture{
                                    file.import.data = file:current:originalUid // file:current:uid    
                                }
                                device = desktop
                                type = w
                            }
                        }    
                    }
                }
            }
            12 = IMG_RESOURCE
            12{
                stdWrap.noTrimWrap = | data-src-retina="|"|
                file.import.data = file:current:originalUid // file:current:uid
            }
            13 = TEXT
            13{
                data = file:current:name
                replacement{
                    10 = TEXT
                    10{
                        search.cObject = TEXT
                        search.cObject{
                            wrap = .|
                            data = file:current:extension
                        }
                        replace =
                    }
                }
                override.data = file:current:alternative
                stdWrap{
                    required = 1
                    noTrimWrap = | alt="|"|
                }   
            }
        } 
    }
    20 = COA
    20{    

#####################这里是问题##################

 stdWrap {
        innerWrap = <div class="start-box-bg"><div class="start-box-txt">|</div></div>
        typolink.parameter = 3
        } 


        23 = TEXT   
        23{
            field = header
            wrap = <h4>|</h4>
            replacement{
                10{
                    search = |
                    replace = &shy;
                }
            }    
        }
        24 = TEXT
        24{
            field = bodytext
            parseFunc =< lib.parseFunc_RTE
        }
        25 = TEXT
        25{
            data = LLL:fileadmin/{$folderName}/Resources/Private/Language/template.xml:content.stratbox.link
            typolink{
                parameter.field = header_link
                ATagParams = class="btn"
            }
        }

    }
    30 = TEXT
    30{
        wrap = <div class="teaser"><h4>|</h4></div>
        field = header
        replacement{
            10{
                search = |
                replace = &shy;
            }
        }
    }
}

它没有产生预期的结果,出了什么问题? 他正在关闭一个标签,或者他只包含内容,而不是整个div:

<div class="start-box-wrapper link">
<img ... />
<!-- this content is sliding over the image -->
    <a href="header_link"> header text</a>
    <div class="start-box-bg" style="left: -100%;">
    <div class="start-box-txt">
    <a href="header_link">
    <h4>header</h4>
    </a>
    <a href="header_link">
    <p class="bodytext">Lorem Ipsum </p>
    </a>
    </div>
</div>
    </div>

2 个答案:

答案 0 :(得分:1)

以下代码段生成所需的输出。它使用TYPO3 7.6.x进行测试。

page = PAGE
page {
  typeNum = 0

  10 = COA
  10 {
    stdWrap {
      innerWrap = <div class="start-box-bg"><div class="start-box-txt">|</div></div>
      typolink.parameter = 3
    }

    10 = TEXT
    10 {
      value = Test
      wrap = <h4>|</h4>
    }

    20 = TEXT
    20 {
      value = More text to go with lorem ipsum.
      wrap = <p>|</p>
    }
  }
}

生成的HTML如下所示:

<a href="index.php?id=3">
  <div class="start-box-bg">
    <div class="start-box-txt">
      <h4>Test</h4>
      <p>More text to go with lorem ipsum.</p>
    </div>
  </div>
</a>

根据作者的给定代码段,生成以下HTML:

<div class="start-box-wrapper link">
    <a href="index.php?id=3">
        <div class="start-box-bg">
            <div class="start-box-txt">
                <h4>Title &shy;&shy; mit Separator</h4>
                Ich <link 38>bin</link> <b>Bodytext</b>.<a href="index.php?id=28" class="btn">Test</a>
            </div>
        </div>
    </a>
    <div class="teaser"><h4>Title &shy;&shy; mit Separator</h4></div>
</div>

答案 1 :(得分:1)

对于这种特定情况,问题是由无效的HTML引起的。复杂的TypoScript代码生成嵌套的a-tags。浏览器的控制台不显示“正确”的HTML输出。 HTML源代码显示了嵌套。因此删除内部a-tag可以解决问题。