Call tx_blog viewhelper from other extension - typo3

I'm using the Typo3 blog extension (tx_blog) for my website. In the blog template the link for the category overview comes from the viewhelper blog:link.category. It creates a nice URI without query parameters or chash (/blog/category/flowers) as configured.
I now need to create a link to the same category page from a template from another extension. Using the same viewhelper gives me the above uri but it adds the controller and action from my own extension as query parameters.
So I copied the viewhelper and changed the urifor call to pass on the values of the blog extension. The action when set to NULL is gone, but the controller is still added. Also the chash parameter is still there.
How can I get the right URI from a different extension context?

You can use any ViewHelper installed in the system by registering it in the template head.
Example:
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:v="http://typo3.org/ns/Vendor/ExtensionKey/ViewHelpers" data-namespace-typo3-fluid="true">
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" means that the namespace f can be used for the default TYPO3 ViewHelpers.
xmlns:v="http://typo3.org/ns/Vendor/ExtensionKey/ViewHelpers" is a registration of all ViewHelpers of the Extension Vendor/ExtensionKey, which can be used in the template with the namespace v.
data-namespace-typo3-fluid="true" means that the <html> element won't be in the output.

Related

TYPO3: filter tx_news categories by arguments in the URL

I have a website with TYPO3 v10 and tx_news. I like to know if it is possible to filter categories with arguments in URL something like:
www.mywebsite.com/index.php?id=9&tx_news_pi1%5Bnews%5D=350&tx_news_pi1%5Bcontroller%5D=News&tx_news_pi1%5Baction%5D=list&categories=12
In this example the link will lead to a page where all news items belong to category id=12.
Thanks for any hints.
Yes this is possible by adding the parameter in a form that its handed over to the plugins extbase controller. For tx_news the parameter you ask for looks like:
&tx_news_pi1[overwriteDemand][categories]=12
You can even make the parameters shorter and more readable by using RouteEhancers in your site: https://docs.typo3.org/p/georgringer/news/8.5/en-us/AdministratorManual/BestPractice/Routing/Index.html

TYPO3: tx_news modify news forms

I'm working on a magazine page. Therefor I would like the client to be able to select the design type when creating/editing a new post. So I'd like to add a custom field to the "edit news", something like a dropdown where all the news (design) types are listed.
For example: News Types:
Normal
Interview
Date
Special Event
etc...
When the client doesn't select anything it should fallback to a default i.e "Normal" and also it would be nice that when the client selects Interview a second input field shows up where he can enter the persons profession/description.
My goal is, that in the fluid template I can add a line where the selected news type will be added as a class to the list item, something like:
<div class="news-item {newsItem.type}">
// some code
</div>
will render out as:
<div class="news-item interview">
// some code
<div>
I'm not quite sure what I have to add to my custom extension that I'm using to accomplish that.
I appreciate all the help.
you need to extend the news data with further fields. This is described in the manual and this blog(ext:news is extended, but filestructure is old) and this article(current fielstructure, but other tabel is enhanced).
For the evaluation and displaying of your fields you need to modify the templates of ext:news. copy the neccessary parts into your extension and provide the modifications to it.
Also set the typoscript to include your templates like described in the manual.

Friendly url creation FLUID

I'm developping a TYPO3 extension (TYPO3 6.2) and I'm trying to create a link with parameters.
My working link is like this:
........./?param1=val1&param2=val2
Now I'm trying to make this url more friendly and want to show it as:
........./val1/val2
but when I access this url, I have a TYPO3 error saying:
Reason: Segment "val1" was not a keyword for a postVarSet as expected on page with id=MYID.
The url is created with FLUID:
<f:link.page pageUid="MYID" additionalParams="{tagid: '{var.id}'}">More</f:link.page>
Thanks for your help!
It's not about Fluid, but missing RealURL config, there are two good articles written by Dmitry Dulepov - RealURL author:
http://www.dmitry-dulepov.com/2008/05/realurl-made-easy-part-1.html
http://www.dmitry-dulepov.com/2008/06/realurl-made-easy-part-2.html

typo3: is there a way to see the pages and its html templates in one place?

in typo3 admin site, I am using TemplaVoilà to make html templates. I have many pages in my site, so I wonder if there is a way that I can check which page is using which html template in one overall page, instead of checking it one by one, something like:
contact page: home.html
employer page: employer.html
...
You can use a hook to add this information in the TemplaVoila s module.

How can I render a link on a Powermail confirmation/submit page?

I'm trying to place a link on the submit page of my powermail setup.
You'd think this is a simple task, but bear with me.
My Powermail form has 2 hidden fields which are prefilled with a page ID and a page title.
These belong to the page I later want to return to, after having sent the mail. By putting these values in the form, I hoped to have access to them whenever I need them in the process.
I prefill these hidden fields from TypoScript like so:
plugin.tx_powermail {
settings {
setup {
prefill {
// Hidden "back to" page ID. This is the page you may want to return to after sending a mail.
backto = TEXT
backto.data = GP:backTo
backto.if.isTrue.data = GP:backTo
backtotext = TEXT
backtotext.noTrimWrap = |Back to ||
backtotext.data = GP:title
backtotext.if.isTrue.data = GP:title
backtotext.htmlSpecialChars = 1
}
}
}
}
1. Approach
Given that Powermail claims you can now use Fluid ViewHelpers in your content sections, I though, great, let's use the PageViewHelper, like so:
{f:link.page(pageUid:'{backto}')}
But where does my link text go? More inline notation to the rescue!
{backtotext -> f:link.page(pageUid:'{backto}')}
Rendered Result
Seems like the inline notation is not fully supported. I thought I was smart by simply using:
{f:link.page(pageUid:'{backto}')}{backtotext}
But this leaves the <a> tag open, which has very undesirable effects...
So - No link for me!
2. Approach
So I thought I would simply construct the link in TypoScript and render it on the page via
{f:cObject(typoscriptObjectPath:'lib.myBackLink')}
But I can't see any way to access the variables from the (sent) Powermail form in TS. So I don't have access to the page ID or title.
3. Approach
So I thought, if the default PageViewHelper only wants to render its children as its content, maybe I can roll my own ViewHelper that accepts the content as a parameter!
But how would I make that ViewHelper known to the system so that I can use it in my customized Powermail templates?
I've only used Fluid inside of my extensions before. It was obvious how Fluid would look up the correct ViewHelper by name, by what if I want to use a ViewHelper in my fileadmin folder hierarchy?
4. Approach
So, why not just use a normal link by using {backtotext} in the RTE?
TYPO3 realizes, that that is an illegal reference, and quickly turns the link into:
And the resulting output will simply not be a link.
So, that doesn't work either.
OK, so I change the target to {backtotext} (removed a slash). Now the URL is no longer recognized as internal and is marked with data-htmlarea-external="1". This causes my link to actually be fully evaluated and rendered (yay).
But it is now treated like an external link, RealURL no longer affects it and it is subject to external link _target behavior.
Why is this so difficult? What am I not understanding?
In RTE you have to use <link ###pageid###> instead of <a href="...">.
Have a look into the RTE DB field contents (or hit the no RTE checkbox) on how to use the link elements.
As it turned out, none of the previously attempted solution actually worked.
To get things over with, I just replaced the web section in the PowermailAll template, like so:
Section for Web view
<f:section name="web">
</a>
</f:section>
And then I used the following in my Submit Page content:
{f:link.page(pageUid:'{backto}')}{backtotext}{powermail_all}
Problem solved. I guess...