In the template setup I have set two columns up like this:
column1 < styles.content.get
column1.select.where = colPos = 1
column1.stdWrap {
wrap = <div>|</div>
required = 1
}
column2 < styles.content.get
column2.select.where = colPos = 2
column2.stdWrap {
wrap = <div>|</div>
required = 1
}
This wraps the column with a div but only if there is something in it.
Is there a way to put a wrap around BOTH columns if at least one of them has content?
At the moment I am achieving this using CSS :empty {display:none;} on the wrap in the template partial, but I would rather do it in Typoscript because :empty is not supported everywhere.
The clean solution would be:
Either you define a COA in typoscript:
column_1_and_2 = COA
column_1_and_2.10 < .column1
column_1_and_2.20 < .column2
column_1_and_2.wrap = <div>|</div>
or you use a little bit of logic in your fluid:
<f:if condition="{column1}{column2}">
<div>
{column1->f:format.raw()}
{column2->f:format.raw()}
</div>
</f:if>
DON'T try to build logic with splitted wraps.
Related
I want to adjust my rendering of layout and frame elements in the frontend.
I have different layouts defined via typoscript. Now I want to define two frames, that should adjust the wrapped elements on layout level.
Currently the two layers (layout and frame) gets rendered like the following:
(exact classes might differ)
<div class="layout-class">
<div class="frame-class">
<p>This is Content</p>
</div>
</div>
I want to change that behaviour via Typoscript to render it like the following:
<div class="layout-class frame-class">
<p>This is Content</p>
</div>
Is there a possibility to do so?
I tried the following:
tt_content.stdWrap.innerWrap.cObject = TEXT
tt_content.stdWrap.innerWrap.cObject {
field = frame_class
required = 1
noTrimWrap = |field:frame_class-| |
}
Solution 1:
tt_content.stdWrap.innerWrap.cObject = COA
tt_content.stdWrap.innerWrap.cObject {
10 = TEXT
10.field = layout_class
20 = TEXT
20.field = frame_class
20.wrap = -|
}
Solution 2:
tt_content.stdWrap.innerWrap.cObject = TEXT
tt_content.stdWrap.innerWrap.cObject {
value = {field:layout_class}-{field:frame_class}
stdWrap.insertData = 1
}
Deactivate css_styled_content
Activate fluid_styled_content
Adjust your project's stylesheet to fluid_styled_content classes
Can I add a custom field to each content-element where I can add a string?
In typoscript I would be able to read this string and print it in class="" attribute is that possible?
There is the note field for each content element Can I red this in typoscript and paste it in the class attribute?
CONTENT < styles.content.get
CONTENT.renderObj.stdWrap.dataWrap=<div class="{NOTE??}">|</div>
Thanks
UPDATE:
Is something like this possible:
CONTENT < styles.content.get
CONTENT.renderObj.stdWrap {
key.field = layout
4 = TEXT
4.value = <div class="csc-default blue">|</div>
5 = TEXT
5.value = <div class="csc-default meineklasse2">|</div>
6 = TEXT
6.value = <div class="csc-default meineklasse3">|</div>
}
As to stay with a given CI it normally is no good option to enable editors to enter CSS-class names by hand. A better way would be to have a set of possible classes the editor can choose from.
This can be done if you use the already available field layout in the tt_contentrecord.
As the layoutfield is type int you might need a 'translation' to your expected class names, or you stay with numbered classes like frame-layout-1 to frame-layout-3. This is the (in FSC) build in solution and available option.
You can enhance this option and also modify it.
Enhancing the selection is done in page TSconfig:
// Adding more layouts:
TCEFORM.tt_content.layout.addItems {
4 = my special layout
5 = my other special layout
}
// Modifying layouts names:
TCEFORM.tt_content.layout.altLabels {
1 = my default layout
}
// remove items
TCEFORM.tt_content.layout.removeItems = 2,3
In FSC this field is evaluated in the layout template (Resources/Private/Layouts/Default.html) (if you also use a frame_class ????)
[...]
<div id="c{data.uid}" class="frame frame-{data.frame_class} frame-type-{data.CType} frame-layout-{data.layout}{f:if(condition: data.space_before_class, then: ' frame-space-before-{data.space_before_class}')}{f:if(condition: data.space_after_class, then: ' frame-space-after-{data.space_after_class}')}">
[...]
But you can override the Default.html file with your own, like in every fluid templating system. Just copy the original file to your own space and add the new location to the template (Layout) paths.
That could end in something like:
[...]
<div id="c{data.uid}" {f:render.section(name:'layout-selection', arguments={layout:'layout'})} ... >
[...]
<f:section name="layout-selection">
<f:switch expression="{layout}">
<f:case value="1">class="normal"</f:case>
<f:case value="4">class="special"</f:case>
<f:case value="5">class="very-special"</f:case>
<f:defaultCase>class="default"</f:defaultCase>
</f:switch>
</f:section>
based on the version of your TYPO3 the template paths of FSC can be configured like:
(up to TYPO3 7):
lib.fluidContent {
templateRootPaths {
20 = EXT:my_extension/Resources/Private/Templates/
}
partialRootPaths {
20 = EXT:my_extension/Resources/Private/Partials/
}
layoutRootPaths {
20 = EXT:my_extension/Resources/Private/Layouts/
}
}
or (since TYPO3 8): (Manual)
lib.contentElement {
templateRootPaths {
20 = EXT:my_extension/Resources/Private/Templates/
}
partialRootPaths {
20 = EXT:my_extension/Resources/Private/Partials/
}
layoutRootPaths {
20 = EXT:my_extension/Resources/Private/Layouts/
}
}
I found a solution which works for me.
tt_content.stdWrap.innerWrap.cObject = CASE
tt_content.stdWrap.innerWrap.cObject {
key.field = layout
4 = TEXT
4.value = <div class="blue"><div class="container-fluid"><div class="design">|</div></div></div>
5 = TEXT
5.value = <div class="white"><div class="container-fluid"><div class="design">|</div></div></div>
6 = TEXT
6.value = <div class="grey"><div class="container-fluid"><div class="design">|</div></div></div>
}
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.
I made a special panning sub menu with icons which can be inserted choosing a specific backend_layout named pagets__panmenu , if that layout is selected the main menu should not display a sub menu and link to the page instead of opening a sub ...
I work with typo3 V7.6.11 and fluid styled content
The part reading the value works correctly:
NO = 1
NO {
before.cObject = LOAD_REGISTER
before.cObject{
panmenu.cObject = TEXT
panmenu.cObject.data.dataWrap = DB:pages:{field:uid}:backend_layout
}
ATagBeforeWrap = 1
wrapItemAndSub = <li>|</li>
stdWrap.htmlSpecialChars = 1
}
This is my best effort to match, but its not working:
IFSUB <.NO
IFSUB {
wrapItemAndSub = <li class="dropdown">|</li>
wrapItemAndSub.override = <li>|</li>
wrapItemAndSub.override.if {
value.data = register:panmenu
equals = pagets__panmenu
}
ATagParams = class="dropdown-toggle" data-toggle="dropdown"
ATagBeforeWrap = 1
}
I know that also the 2 < .1 has to be suppressed, I'm trying to get the if to work to keep the style and link clean for starters ...
First of all: have you set TMENU.IFSUB = 1?
Else, everything you do in IFSUB won't have an effect.
Now some general thoughts:
a) Normally, backend layouts are used to switch an entire page template:
page.10 = FLUIDTEMPLATE
page.10 {
file.stdWrap.cObject = CASE
file.stdWrap.cObject {
key.data = pagelayout
default = TEXT
default.value = {$myTemplatePath}/Standard.html
1 = TEXT
1.value = {$myTemplatePath}/Home.html
2 = TEXT
2.value = {$myTemplatePath}/Landing.html
}
layoutRootPath = {$myLayoutPath}
partialRootPath = {$myPartialPath}
}
So this initiates the frontend rendering for the entire page, where backend_layout with uid 1 will use the Home.html template, backend_layout with uid 2 will use the Landing.html template, and all others (=default) will use the Standard.html template.
If you build your site by this method, I would recommend doing
# that's the original version of your menu
lib.panmenu = HMENU
lib.panmenu {
// ...
}
# make a copy of the original
lib.panmenu_variant < lib.panmenu
# modify it as required
lib.panmenu_variant.1.NO {
// ...
}
Now, in your page Templates (which you call separately via the CASE from above), you can either use
<f:cObject typoscriptObjectPath="lib.panmenu" />
or
<f:cObject typoscriptObjectPath="lib.panmenu_variant" />
b) But if you don't want to follow that approach, you should also be able to use the backend_layout CASE on any cObject. The CASE variant has proven much more robust for me.
Here' how I'd try to get the CASE working (untested!)
// suppose temp.navigation_main is your full menu
temp.navigation_main_variant < temp.navigation_main
temp.navigation_main_variant {
// modify the menu as you please
10.2 >
10.1.IFSUB.wrapItemAndSub = <li>|</li>
}
// use lib.nav in your page
lib.nav = CASE
lib.nav {
key.data = pagelayout
// normally, lib.nav is the full navigation
default < lib.navigation_main
// except if be layout 1 is selected
1 < lib.navigation_main_variant
}
}
c) I've tried TypoScript constructions with LOAD_REGISTER and ifs years ago and they always made me go crazy. I wouldn't invest too much energy into them, as they rather seem to be legacy parameters than the future way of development for TYPO3 logic.
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