tx_news Paginate with dynamic variables - typo3

I have created a custom template for paginations. But I want to display a count of all news articels and so I'm looking for a solution to pass a variables to the pagination. I don't want to build a custom viewhelper, I want to stick with the original PagionationViewhelper.
Maybe have anyone a idea?

Make the counting with a cObject like lib.newscount
then you pass that with the cObject Viewhelper like:
<f:cObject typoscriptObjectPath="lib.newscount"></f:cObject>

Related

Condition for backend layout name in Typo3 10+

I'm looking for a way to render a partial for when an element is placed it on a part of the backend layout and another partial for when the same element is placed it on another part of the backend layout.
My backend layout names are "Header" on top and "Normal" on the bottom. I want to render text-media element with one partial for when is on Header and another partial for when is on Normal.
For what I could find online seems that this must be done with typoscript. Particualrly I want to use typoscript condition because is the one that make more sense on my head.
I'm aware of this but the answers are not helping me at all.
This is the one that looks like something I could use.
[page["backend_layout"] == 'pagets__2']
page.bodyTagCObject.value.wrap = <body id="uid|" class="fullpage">
[end]
Any help is welcome even tutorials because clearly I have much to learn about typoscripting
You can pass the needed value as a variable to your FLUIDTEMPLATE-object.
The current backend-layout is available as pagelayout (Already with the 'backend_layout_next_level' taken into account).
page.10 = FLUIDTEMPLATE
page.10 {
variables {
pagelayout = TEXT
pagelayout.data = pagelayout
}
}
Solved it.
I have been able to solve this problem without useing Typoscript. (so I will keep ignoring typoscript :D )
Dropping the variables of the loaded templates (not partials) made me realized that there was a property holding the colPos of the backend layout so all I had to do was an if condition on the textmedia default template.
<f:if condition="{data.colPos} == 1">
If the colPos of the backend layout is 1 print something
</f:if>

How can I pass one parameter or value from fluid to typoscript

I want to pass a value from my fluid code to typoscript. I have two variable (one is int, the other is some text) and I want to use those values in typoscript. Is that possible and if it is possible how?
I want to use the values to create opengraph tags in head of HTML.
Here's my TypoScript
lib.getuserItems = TEXT
lib.getuserItems.wrap = |
page.meta {
og:description < lib.getuserItems
og:description.attribute = property
og:locale = de_DE
og:locale.attribute = property
}
and here's my Fluid
<f:cObject typoscriptObjectPath="lib.getuserItems" data="{article.description}" />
Your problem will not be the parameter transfer.
If you use <f:cObject> in fluid you can compute something with typoscript which is returned and can be used to render the fluid template.
You want some data from your fluid-template transferred to the page configuration (page.meta....) which is not possible in this way.
If you want to set those meta tag data you can use viewhelper in fluid, but that must be PHP viewhelper, that can access page configuration and set these data.
Be aware that TYPO3 9LTS has introduced an API for metatags

assign custom function call to variable

I am quite new to Typo3 and Fluid, but I guess what I am after is quite basic.
As an Analogy: Twig can extended, so it is possible to create a custom function which can be used like that:
{% set id = uid() %}
<input id="{{ id }}" … /><label for="{{ id }}">…</label>
Is such a thing possible with Fluid? Do I need to install other extensions, or can that be done with basic fluid extension?
In Fluid you have two ways to achieve this:
Prepare the desired data in the controller and assign it to the view as variable.
Create a custom viewhelper which contains the logic to build the desired data.
You can also combine these two and store the result of a viewhelper call in a variable using the f:variable viewhelper (more usage examples):
<f:variable name="myvariable">{acme:custom.viewhelper()}</f:variable>
In this specific case you can also install the VHS extension, the swiss army knife of Fluid, and use its UniqIdViewHelper Notice that you normally don't need this for forms since you bind them to (domain) objects you want to create/edit and let Extbase/Fluid handle the rest.

Wrap H1-H6 Tags with Typo3 ParseFunc depending on the class set in RTE

I want to add inline-svgs to my h1 to h6 Tags depending on the class set in the RTE.
Example:
RTE:
<h1 class="icon--clock">Header</h1>
Output:
<h1 class="icon--clock"><svg>...</svg>Header</h1>
I've done something similar with links before, using the parseFunc Config. A method like this: https://wiki.typo3.org/External_links
Is there any way to access and split the tag and class like the link parameters through TypoScript?
I also tried using a userFunc
lib.parseFunc.userFunc = ...\MyClass->MyUserFunc
but in Params I only get the tag content, not the tag or the classes that have been set themselves.
I'm using Typo8 with the ckeditor, but I don't think that makes a difference.
Can I even do this?
How do I do this?
I know that I can alternatively add different header layouts and use the tt_content header field, because it's easier to manipulate the template there. But I'd love to know if there is a way to this in the RTE.
I think you could do it in typoscript, but that would be very complicated as you need to analyze the attributes of the Hn-tags.
A simpler method which came to mind would be: use CSS and ::before. So you can use a selector to the class to insert the matching SVG.
This also can be done with javascript but as CSS can do it it would be more efficient to use CSS.

TYPO3: category tree of tx-news, render sub-tree only if main is selected

I override Templates/Styles/TWB/Templates/Category/List.html to have the category menu behave exactly as the sidebar menu in the introduction package (submenus show only if main is selected).
If I add the static template "News Styles Twitter Bootstrap (news)" I'm almost there, it is not difficult to open the sub-categories only if the main category is selected (I need a massive amount of categories/sub-categories), but it should also be open when a sub is selected:
...
<f:if condition="{0:category.item.uid,1:category.item.uid} == {0:overwriteDemand.categories,1:category.children.{overwriteDemand.categories}.parent}">
<f:if condition="{category.children}">
<f:render section="categoryTree" arguments="{categories: category.children,overwriteDemand:overwriteDemand,class:''}" />
</f:if>
</f:if>
...
I do not know how to use {overwriteDemand.categories} as key to match the value ... can anybody point to the proper syntax
update: I tried to apply a custom ViewHelper as this post suggests, but using TYPO3 V7.6.16 got stuck with the error should be compatible with TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper:‌​:render(), so could not try working with the variable overwriteDemand.categories in another way ...
Dynamic access to variables in fluid is just possible since TYPO3 8. Check out the Whats New Slides here: https://typo3.org/download/release-notes/whats-new/ and search for "Dynamic variable name parts" in the PDF.
In TYPO3 7, the "vhs"-Extension provides a ViewHelper to do the same job but nesting a ViewHelper within an complex f:if-condition is even more difficult. If possible, try out TYPO3 8. If it's not possible you may write your own ViewHelper to solve this logical problem.