1
votes

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

sys_category TYPO3


example some categories overall TYPO3

  • `{data} {data}
3
What is {categories}? Is it array or ObjectStorage? Is it properly mapped in your Domain Model? Please, provide more info. - Viktor Livakivskyi
TYPO3 Overall Categories (== System records in table sys_category), see my edit ..screenshot - user2310852
I see now. I didn't work with system categories yet, but most probably you should iterate through them via f:for ViewHelper, and then you can fetch an id - Viktor Livakivskyi
Ok, thanks. I see, that <f:debug>data</f:debug>only get an bool variable (1 or 0). With the f:forViewHelper, I only get the uid, not the title. So that's not enough. I will find another way to get my class into the template. thanks - user2310852
I've created a feature request for fluid: forge.typo3.org/issues/82010 - cweiske

3 Answers

1
votes

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.

1
votes

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}" />
0
votes

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.