TYPO3 render uncached content element on a dedicated page - typo3

I would like to render a page which just has a tt_content element on it (so I can Ajax it into another page). However, due to the way it needs to be set up, this content element needs to remain uncached until rendered.
The same plugin renders perfectly fine when adding via TYPO3, however I want to be able to taget this plugin via JavaScript (without having to load the whole page again).
How can I render the content on the page? When I do the following I get the uncached INT_SCRIPT marker - is there anyway I can force this to render on page load (or make it a “cached” element when selected?
$content = $TSFE->cObj->cObjGetSingle('RECORDS', [
'tables' => 'tt_content',
'source' => 123
]);
$response->getBody()->write($content);
I'm using TYPO3 9.5.
Thanks for any help in advance.
(I found this but the solution doesn't work: How to render INT_SCRIPT in StandaloneView?

You could work with a simple uncached page setup provided as another page type and then target that page with your AJAX call.
A solution for that approach has been provided here: TYPO3 Ajax Page Configuration

Related

Kentico and add Form that posts to external source

I want to create a Salesforce Web to Case from on my Kentico Site.
I have a template built and am inheriting the from that.
I create a new page and then add my form code to the Page Tab > Source and Save.
When I load the page on my site, the form is displayed, but when I hit submit, the form does not do the post action.
How do I accomplish this?
TIA, Jason
Since Kentico is built on web forms, each page's content is wrapped inside a form tag.
Adding your markup (including a form tag) in the middle of a Kentico page results in a nested form, which is invalid.
The quickest way to make this work is probably:
Create a basic HTML document with your markup, and put it on a new page in a "Custom Response" web part. https://www.screencast.com/t/PuwwnFTGGpAJ
Then display that new document in an iframe on your current page.
If that won't work, you can put your form markup in a div hidden by CSS. Then use javascript to move the div to a location after the page's main form tag. You can then use CSS to absolutely position the form on the page.
I hope this is helpful, good luck.

How to manipulate the meta area of the HTML dom with Scala-JS for a single page application

General Scala-JS page building advice needed. Most of the examples seem to be of the pattern where the main into which your single page application will go is between the tags in a landing page html file. How do you handle the need to insert something in the meta area of the dom? Do I need to render my landing page dynamically from the server to accomplish this? My specific need is to inject a script tag into the meta area of an already defined static html page. I'm using scalajs-react.
Generally you will want a server-rendered "root page" for the SPA. This allows you to dynamically compute proper cache busting file names for your script and stylesheet tags and to easily manage the cache expiration of the root page. Also, for proper html5 push state support you'll want to serve that page at every URL, which is easily done with a server side route.

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

<fb:comment> tag not working properly

I have a GWT app and Im trying to put fb social plugin comment in side of my page. However I have the folowing problem.
If I put the tag in my .html it works perfect, but If I put id dynamically (like with an HTML widjet), It does not work. It just does not display anything.
Can anyone help me? Im having this problem in general, not only with the fb:comment tag.
Note: If I use the iframe implementation of, for example, "fb:like", it works perfect.
My understanding of facebook's api is that it loads your content, and parses out the tags in the fb namespace, replacing them before the actual content is drawn for the user. In contrast, none of the GWT compiled code (or indeed any Javascript code) gets a chance to make changes to the dom until the page has loaded in the browser fully, after facebook has made the changes it needs to.
My advice: Put the fb namespaced tags on the initial page, but perhaps wrap them in a div and mark them as display:none. Then you can grab them from your GWT code and wrap them up in a widget, only to be displayed when you are ready.