简体   繁体   English

TYPO3打字稿mySql Select,获得相同的db字段2次

[英]TYPO3 typoscript mySql Select, get the same db field 2 times

newbie to TYPO3 but learning. TYPO3的新手,但正在学习。

I have this code 我有这个代码

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>
    }   
}

Working fine, now i want to add an extra field from my DB, and i have this code, and its also working. 工作正常,现在我想从数据库中添加一个额外的字段,并且我有此代码,它也可以正常工作。

......
    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>
    }   
}

Now my question is, is this code OK, and how do i add the "subcategorytitle" at the title="###" so i dont need to make a 3. 30 = TEXT and and the same field from the DB to times like this, or is it the way to do it ? 现在我的问题是,此代码是否正确,以及如何在标题=“ ###”处添加“ 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
    }   
}

The second example you gave is perfectly fine, but you might get a problem with a missing space between the title and the data-filter attributes in your output. 您提供的第二个示例很好,但是您可能会遇到title与输出中的data-filter属性之间缺少空格的问题。 Look into the stdWrap property noTrimWrap to solve that. 查看stdWrap属性noTrimWrap来解决该问题。

Another problem with you code is that you miss escaping the data from the database, which also makes it potentially vulnerable against XSS attacks. 代码的另一个问题是,您错过了从数据库转义数据的权限,这也使它可能容易受到XSS攻击。 You can solve that using the stdWrap-property htmlSpecialChars . 您可以使用stdWrap-property htmlSpecialChars解决此问题

......
    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>
        }
    }   
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM