新手到TYPO3但是学习。
我有这段代码
lib.GetSubCat = CONTENT
lib.GetSubCat {
wrap = <div class="p_filter"><div class="p_filter_container"><a class="p_cat_filter button" href="#" title="Under Emne" data-filter="article.portfolio"><span>Under Emne</span></a><ul class="p_filter"><li class="current"><a href="#" title="Under Emne" data-filter="article.portfolio">Under Emne</a></li>|</ul></div><div class="cl"></div></div>
table = tx_tbpdrills_domain_model_drillsubcategory
select {
pidInList = 18
where = NOT deleted AND NOT hidden
orderBy = subcategorytitle ASC
}
renderObj = COA_INT
renderObj {
10 = TEXT
10.field = subcatshort
10.wrap = <li><a href="#" title="###" data-filter="article.portfolio[data-category~='###']">|</a></li>
}
}
工作正常,现在我想从我的数据库添加一个额外的字段,我有这个代码,它也有效。
......
table = tx_tbpdrills_domain_model_drillsubcategory
select {
pidInList = 18
where = NOT deleted AND NOT hidden
orderBy = subcategorytitle ASC
}
renderObj = COA_INT
renderObj {
10 = TEXT
10.field = subcatshort
10.wrap = <li><a href="#" title="###" data-filter="article.portfolio[data-category~='|']">
20 = TEXT
20.field = subcategorytitle
20.wrap = |</a></li>
}
}
现在我的问题是,这段代码是否正常,如何在title =“###”添加“subcategorytitle”,所以我不需要制作一个3. 30 = TEXT和来自的相同字段DB到这样的时间,还是这样做的?
lib.GetSubCat = CONTENT
lib.GetSubCat {
wrap = <div class="p_filter"><div class="p_filter_container"><a class="p_cat_filter button" href="#" title="Under Emne" data-filter="article.portfolio"><span>Under Emne</span></a><ul class="p_filter"><li class="current"><a href="#" title="Under Emne" data-filter="article.portfolio">Under Emne</a></li>|</ul></div><div class="cl"></div></div>
table = tx_tbpdrills_domain_model_drillsubcategory
select {
pidInList = 18
where = NOT deleted AND NOT hidden
orderBy = subcategorytitle ASC
}
renderObj = TEXT
renderObj.stdWrap.htmlSpecialChars = 0
renderObj {
value = <li><a href="#" title="{field:subcategorytitle}" data-filter="article.portfolio[data-category~='{field:subcatshort}']">{field:subcategorytitle}</a></li>
insertData = 1
}
}
答案 0 :(得分:0)
您提供的第二个示例非常好,但您可能会遇到输出中title
和data-filter
属性之间缺少空格的问题。查看stdWrap属性noTrimWrap来解决这个问题。
您的代码的另一个问题是您错过了从数据库中转义数据,这也使其可能容易受到XSS攻击。您可以使用stdWrap-property htmlSpecialChars来解决这个问题。
答案 1 :(得分:0)
......
table = tx_tbpdrills_domain_model_drillsubcategory
select {
pidInList = 18
where = NOT deleted AND NOT hidden
orderBy = subcategorytitle ASC
}
renderObj = COA_INT
renderObj {
wrap = <li>|</li>
10 = TEXT
10 {
field = subcategorytitle
htmlSpecialChars = 1
wrap = <a href="#" title="|"
}
20 = TEXT
20 {
field = subcatshort
htmlSpecialChars = 1
noTrimWrap = | data-filter="article.portfolio[data-category~='|']">|
}
30 = TEXT
30 {
field = subcategorytitle
htmlSpecialChars = 1
wrap = |</a>
}
}
}