TYPO3 get category uid at FLUID template (sys_category)

雨燕双飞 提交于 2019-12-13 01:04:23

问题


I try to show my category uid or name as a class="category.uid" at my FLUID template.

If I try <f:debug>{data}</f:debug> I'll see there are an output like: categories => '1' (1 chars)

But how can I write the category-uid or -name into my FLUID/HTML, similar like this:

<div id="container" class="{data.nav_title}">
<!-- I need the categories --> 
<div id="container" class="{categories.uid}">

THanks for your help.

EDIT: some screenshots The info is in table sys_categorytitle, uid, pid ..


  • `{data}

回答1:


The same problem is discussed here (see 11:30 - 12:31).

So there is no viewhelper for this. You have to register a ContentController with Flux.




回答2:


I have used a variant of the solution here: How can I get the category object in Fluid of Typo3 Content Element Pictures?

TypoScript

lib.categories = CONTENT
lib.categories {
    table = sys_category
    select {
        pidInList = root
        selectFields = sys_category.uid
        join = sys_category_record_mm on sys_category_record_mm.uid_local = sys_category.uid
        where.field = recordUid
        where.wrap = sys_category_record_mm.uid_foreign=|
    }
    renderObj = COA
    renderObj {
        1 = TEXT
        1 {
            field = uid
            stdWrap.noTrimWrap = | cat-||
        }
    }
}

Fluid Template

<f:cObject typoscriptObjectPath="lib.categories" data="{recordUid: data.uid}" />



回答3:


Sorry for the answer - i do not have enough reputation to comment.

What is {data}?

Is it something you get from your controller like?

$data = $this->configurationManager->getContentObject()->data;
$this->view->assign('data', $data);

If so, then you will need to do some extra processing in your controller since $data is an associated array and not an object / model with injection of relations.



来源:https://stackoverflow.com/questions/31948964/typo3-get-category-uid-at-fluid-template-sys-category

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!