TYPO3 7.4 display categories - typo3

I'm trying to display the categories of the current page.
Because I'm not that good in TYPO3, I first tried displaying all the categories before trying to display the current one.
The following snippet somehow doesn't work.
lib.categorized_content = RECORDS
lib.categorized_content {
categories.field = selected_categories
categories.relation.field = category_field
tables = tt_content
conf.tt_content = TEXT
conf.tt_content {
stdWrap.field = header
stdWrap.typolink.parameter = {field:pid}
stdWrap.typolink.parameter.insertData = 1
stdWrap.wrap = <li>|</li>
}
wrap = <ul>|</ul>
}
This is where I got this snippet from: https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Records/Index.html#categories
I'm using <f:cObject typoscriptObjectPath="lib.categorized_content" /> to implement it into my template.
Can someone help?

selected_categories and category_field are flexform field (as you can see from the suffix .field of the configuration property) from the Special Menu content element.
You have to replace those with the actual value.

Related

HMENU/GMENU render pages.media field

I am migrating typoscript from TYPO3 6.2 ELTS to 7.x ELTS.
Following code works in 6.2 thanks to activateContentAdapter which is removed in TYPO3 7. https://docs.typo3.org/c/typo3/cms-core/master/en-us/Changelog/7.2/Breaking-66034-DropContentAdapter.html
Is that possible to still use HMENU/GMENU or should I rewrite it totally other way?
lib.navigation.socialmedia = HMENU
lib.navigation.socialmedia{
wrap = <ul>|</ul>
special = directory
special.value = 123
1 = GMENU
1{
NO{
wrap = <li class="first">|</li>|*|<li class="middle">|</li>|*|<li class="last">|</li>
altImgResource.import = uploads/media/
altImgResource.import.field = media
altImgResource.import.listNum = 0
ATagTitle.field = subtitle // title
}
}
}
you still could use GMENU but you need to change the filehandling. As mentioned files are no longer just copied to uploads/media/ but there is a file-handle (sys_filerecord) whose uid is used everywhere.
First substitution: treatIdAsReference
This is a usage for rendering an icon of the first media entry in a text menu (TMENUITEM) before the text (1).
The rendering is inside of the FILESobject which represents an (possible) array. SO it might be a little bit complicated to insert it into an IMGRESOURCEobject (2).
if you just want the resource adapt the renderObj, as this example renders the image (cropped) and generates an <img>tag.
NO.stdWrap.prepend = FILES
NO.stdWrap.prepend {
references {
table = pages
uid.data = current:originalUid // current:uid
fieldName = media
}
renderObj = IMAGE
renderObj {
file {
import.data = file:current:uid
treatIdAsReference = 1
width = 150c
height = 150c
}
altText.data = file:current:alternative
titleText.data = file:current:title
params = class="menu-img"
stdWrap.typolink.parameter.field = uid
}
maxItems = 1
}
(1) with the options of CSS3 and HTML5 and the preferred way of accessibility you have multiple ways to use a clean text menu without 'hiding' text in graphics.
(2) you might use altImgResource.cObject = FILES and render an IMGRESOURCE instead of an IMAGE.
meanwhile (since TYPO3 9) you have menu_processors and you would render the menu with fluid, where you 'navigate' through the pagetree with all properties of each page, including images.

TYPO3: pass variable to typoscript via cObject?

I would like to create a dropdown login form in my menu, like in this example: http://bootsnipp.com/snippets/featured/fancy-navbar-login-sign-in-form
I have this cObject that calls typoscript for the navigation:
<f:cObject typoscriptObjectPath="menu.navbar" />
I need to get the content of the login form somehow into the menu typoscript. Is it maybe possible to pass a variable (in my case the login form) to typoscript via cObject ?
f:cObject has a data Attribute, that can take different kind of values.
Usually the data attribute takes an array and you then can use those values to render content objects using the .field properties in typoscript.
An example:
lib.testFluid = COA
lib.testFluid {
wrap = <div>|</div>
10 = TEXT
10.field = title
10.wrap = <b>|</b>
20 = TEXT
20.field = content
}
If you have TypoScript like that, a data array, that has the keys title and content is expected. Rendering such a content object would possibly look like this in fluid:
<f:cObject typoscriptObjectPath="lib.testFluid" data="{title: 'Hello World', content: 'Foobar'}" />
However, if you just have some "content" (e.g. string content) and want to output it at one place in your content object, you can pass it in as-is and use the .current property in TypoScript to let it use the "current value".
lib.testFluid = COA
lib.testFluid {
wrap = <div>|</div>
10 = TEXT
10.current = 1
10.wrap = <b>|</b>
}
And in fluid:
<f:cObject typoscriptObjectPath="lib.testFluid" data="simple text content" />
or
<f:cObject typoscriptObjectPath="lib.testFluid">simple text content</f:cObject>
Of course data also takes normal variables. Depending on your use case, one of those cases might be what you want.
Edit: However, it seems to be a bit more complicated, if you want to use data together with an HMENU. The nested TMENU instances (or other menus) have different data values because it's being overwritten by HMENU with the current page for that menu entry. You probably have to do some convoluted wrapping, or avoid inserting the desired content in a TMENU/GMENU et cetera. I suggest to instead render the menu completely with fluid in that case.
Edit 2 - Example
Something like this is not going to work:
lib.testFluid = HMENU
lib.testFluid {
special = directory
special.value = 1
wrap = <ul>|</ul>
1 = TMENU
1 {
NO.stdWrap.cObject = COA
NO.stdWrap.cObject {
10 = TEXT
10.field = title
10.noTrimWrap = || |
20 = TEXT
20.current = 1
}
}
}
20.current = 1 won't include the value from data supplied by the fluid viewhelper, because the "data" of TMENU has been changed to the current page by the HMENU content object.
However, it should be possible to wrap a COA or similar around the HMENU to insert the desired content somewhere around the HMENU.

Get rid of "csc-frame" div wrap in TYPO3

Here is my code:
lib.navigation{
10 = RECORDS
10 {
source = uid
tables = tt_content
}
}
Here I'm just creating a menu through content element and I wanted to remove the default div with class=csc-frame csc-frame-frame1 from the rendered content
I used like this:
lib.navigation{
10 = RECORDS
10 {
conf.tt_content.stdWrap.innerWrap.cObject.default = TEXT
source = uid
tables = tt_content
}
}
but this will remove only csc_default div.
This might do the trick. Make sure to include it before the navigation definition.
tt_content.stdWrap.innerWrap.cObject.default >

"Menu of subpages" doesn't work in a Typo3 Fluid template while fetching a record from a page

I'm trying to add a "user controlled" footer in the main layout of a Typo3 Fluid based template.
This means that I've added a backend layout with four columns in a special back-end page called "footer page". A user is able to add content elements in those columns using the WEB > PAGE module.
Whenever a user adds a content element (text, text w/images, bullet lists, etc...) in one of the columns, everything works and the content is correctly displayed.
But when the user tries to add a special menu content element, the menu isn't displayed and the column container stays empty.
the main layout
<body>
...
<div id="footer">
<f:cObject typoscriptObjectPath="lib.footer" />
</div>
</body>
main PAGE typoscript
page = PAGE
page {
# Regular pages always have typeNum = 0
typeNum = 0
10 = FLUIDTEMPLATE
10 {
#file = {$filepaths.templates}index_f.html
partialRootPath = {$filepaths.templates}partials/
layoutRootPath = {$filepaths.templates}layouts/
variables {
...
footer < lib.footer
...
}
}
}
lib.footer typoscript
lib.footer = COA
lib.footer {
10 = CONTENT
10 {
table = tt_content
select.pidInList = {$contentpage.footerPID}
select.where = colPos = 901
select.orderBy = sorting
stdWrap.wrap = <div id="footer-widget-1" class="col205">|</div>
}
20 = CONTENT
20 {
table = tt_content
select.pidInList = {$contentpage.footerPID}
select.where = colPos = 902
select.orderBy = sorting
stdWrap.wrap = <div id="footer-widget-2" class="col205">|</div>
}
...
}
Am I doing something wrong or is it a bug?
Typo3 version is 6.0.4
You may want to have a look at the VHS extension for TYPO3 - it contains one ViewHelper in particular which would let you render content elements from any column on any page (by UID). It can even render content elements from a list of content element UIDs (which you could specify in TypoScript, select in a FlexForm, make editable in the constants editor etc.):
http://fedext.net/viewhelpers/vhs/Content/RenderViewHelper.html
Many times the ViewHelpers from VHS will let you do exactly the same as TS lets you do, but do so directly in Fluid and with the option to manually control the HTML that is output.
Cheers,
Claus aka. NamelessCoder

Typo3 FCE refer filetype of field uri inside class attribute

xI would like to insert the filetype of the inserted file into a a href class:
a href class"icon-filetype-"
i have something like this now:
10 = TEXT
10.field = field_uri
10.wrap = icon-filetype-|
but than i get the hole url inside the class :D
thans for time
(btw, i used these sites as reference, so maybe i give you a start with it:
Typo3 FCE refer a field inside a container field
and http://typo3.org/extension-manuals/rs_linklayout/1.3.1/view/1/3/ )
this is the mapping i use:
<ul class="section-container">
<li>
<a class="" href="#" target="_blank"><span>Item 1</span><span class="size"></span></a>
</li>
</ul>
did not test this code:
10 = TEXT
10.field = field_uri
10.split {
token = .
# if you get an different part or some parts added, this optionsplit is wrong
cObjNum = |*||*| 1 || 2
# render nothing means remove this part
1 = TEXT
1.value =
# render only the filetype
2 = TEXT
2.current = 1
}
10.wrap = icon-filetype-|