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

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

Related

AEM RTE with standard Hyperlink plugin cached on dispatcher do not get shortened for second , third links on same line

Issue image I’m having this issue when Using a standard RTE plugin hyperlink feature in AEM.
Clicking on the < ahref> links work correctly where it routes me to a correct shortened URL (/usa-en/delete/smart-factory.html) as expected.
However hovering on the link or view source of the markup generated seems to an issue where links shows an absolute path with (/content/te-com/usa/en/pages/….) which is impacting our SEO.
In fact Only the first link is getting shortened and all other links show an absolute path (/content/te-com/... path) when I hover over the links. I suspect that the cached links have an issue with the path getting shortened.
Node storage in JCR:
<p>Hello one and two. </p>
Generated HTML markup from source :
<div class="global-rte-std-bold global-labels parbase section"><p>Hello one and two. </p>
However when I add a shift + Enter when using the RTE a tag is added and the URL somehow gets shortened for all the links as expected as shown in the below markup. Node storage is still the same as above like the one without shift+enter
Markup Generated (observe that the URL's are shortened):
<div class="global-rte-std-bold global-labels parbase section"><p>Hello one and<br>two. </p>
Also we have the below rewrite rule in Apache that actually comes into effect when I click the link. I suspect the cached URL's with RTE have this issue.
RewriteRule ^/?usa-en/?(.*)$ /content/te-com/usa/en/pages/$1 [PT,QSA].
Note : We have not customized the RTE plugin and its a standard Hyperlink plugin we have been using on AEM 6.2
Code used here is a simple
I wonder how it works correctly with a shift + Enter and not when I have the links on the same line.
Any help on this would be appreciated. Thanks
When you link an internal page/asset with RTE editor then url shortening does not work. I came across the same situation and for this I had to write custom Sling rewriter to transform the link so that resourceResolver.map(path) works fine.
#Override
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
int hrefIndex = atts.getIndex("href");
String href = atts.getValue("href");
atts.setValue(hrefIndex, resolver.map(href));
}

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.

What portions of the marketo code snippet can change?

My company is using marketo forms, and we are generating the page from a content management system.
We'd like to keep the contribution experience as simple as possible and prevent the user from contributing actual <script> tags.
The API documentation says they will give you a block of code that looks like this:
<script src="//app-sjqe.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_621"></form>
<script>MktoForms2.loadForm("//app-sjqe.marketo.com", "718-GIV-198", 621);</script>
My question is, what portions of this code are subject to change?
I am sure the 3 part hypen separated string and the integer being passed in can change.
What about the app-sjqe.marketo.com address?
The 3-part string is your Marketo instance ID, and shouldn't really change. The other integer is the form ID, which definitely will change depending on what form you want to embed.
The other thing that you may want to consider, is the other configurable options that you can send along with the form embed. For example, in the module that I have made for my CMS, I let the user put an optional 'thank-you' page URL, to redirect the form to after submission, and also a checkbox to optionally open the form in a lightbox on page load.
The simple module I made is for the Sitefinity CMS - happy to share code with you if that helps!

Fluxfield for internal Link with pagetree

How can I create a fluxfield to create a link to another page, where the user can chose the page in a pagetree. Something like the Modify Linkfrom the RTE. Is there something?
Or how else would I create a field for a internal link? Just an inputfield where the use can input the PageID is not enough.
One more step would be a field where the user can input an internal link OR an external link.
Have not found any good solution for this problem yet. How do you do it?
You can use a normal text input, but add a link wizard to it. Looks like this:
<flux:field.input
name="link"
label="Link!"
>
<flux:wizard.link/>
</flux:field.input>
To output the link, use one of the ViewHelpers v:(link|uri).typolink from EXT:vhs:
<v:link.typolink configuration="{parameter: link}">
Linktext
</v:link.typolink>
This works for all kinds of links.

In tumblr, show only posts with a certain tag in the home page

In tumblr, is it possible to show only posts with a certain tag in the home page?
If so, how is it done?
I just wrote up the solution to the opposite problem here:
How to hide the posts with a given tag from the homepage.
You can take inspiration from there and implement the opposite. Alternatively, you can simply add a "hidden" tag to each one of the things that you don't want displayed on the homepage.
I know that this topic is quite old, but I figured I'd share what I did for anyone who is still looking for an answer to this problem.
First, paste the following code after the "</title>" in your theme HTML.
<meta name="text:Default Tag" content="" />
Next, right after the "<body>" in your theme's HTML, paste the following:
{block:IndexPage}<script type="text/javascript">
var url = location.href;
if (url == "{BlogURL}") {
window.location = "{BlogURL}tagged/{text:Default Tag}";
}
</script>{/block:IndexPage}
In your theme settings, you should see a box labeled "Default Tag". Put the tag you'd like posts to appear for in that box (without a hashtag) and click save.
Now, if someone visits your blog, it will forward them to the page that shows posts with your specified tag. Of course, this probably isn't the best way of doing it, but it's the best way I could come up with that wouldn't mess up themes.
Another thing I like about this way of doing this, is that you can send someone your blog URL with a "/?" appended to it (e.g. "myblog.tumblr.com/?") and it will show all of your posts.
Using mircealungu's suggestion worked perfectly for me! Here's how I did it:
1. Find the article tag, and add the classname:
class="notfeatured {TagsAsClasses}"
If it already has a classname, add the part in bold above inside the classname quotes. Mine ended up looking like this:
<article id="{PostID}" class="post notfeatured {TagsAsClasses} {PostType}{block:PermalinkPage} {block:Date}not-{/block:Date}page{/block:PermalinkPage}">
2. Find the div tag that precedes the article tag, and add the classname:
class="{block:TagPage} tag_page {/block:TagPage}{block:PermalinkPage}perma_page{/block:PermalinkPage}"
Again, if a class already exists, just add the part in bold above inside the classname quotes. Mine ended up like this:
<div id="posts" class="{block:TagPage} tag_page {/block:TagPage}{block:PermalinkPage}perma_page{/block:PermalinkPage}" >
3. Finally, add this to your CSS:
article.notfeatured {display: none;}
article.featured, .tag_page article.notfeatured, .perma_page article.notfeatured {display: block;}
Now any post tagged as "featured" will display on your home page, but nothing else. So far no issues for me, it works great! You can see it here.
You can also use javascript to reorder the display so you can make the featured posts appear first in a list. The script is very simple:
$('article.featured').prependTo('#posts');
And here is a demo. Just place that inside javascript tags and put it right before the /body tag in your theme. In this case don't use the CSS above, because you don't want to hide the posts. I implemented a .top class for the script and kept the .featured class for the CSS, and I use both the CSS and the script.
Tumblr’s Custom Themes don’t provide such a functionality.
You could use JS or CSS to (visually) hide all posts without a specific tag on the index page, but that way you won’t have the full 10 (or whatever you configured) posts per page anymore.
You could probably use Tumblr’s API to create a list of matching posts (with Javascript) and display that content instead of the default posts (so your custom theme would only contain the script for the index page content). You would have to make sure that the pager still works, though.
Actually, it is possible, but it might not work how you want.
1st. Identify the id of your individual posts (usually something like #post or #entry, lets call yours #entry)
2nd. Replace your opening post div with this:
2nd. Add this bit of css
{block:IndexPage}
#entry (or whatever name it is) {display:none}
.featured {display:inline !important}
{/block:IndexPAge}
3rd. Tag all the posts you want to show on your homepage without quotes as "featured"
This should work, but it will most likely hide all the non "featured" posts on your search page and tag page as well, which you may not want.
If you want your users to be directed to a specific 'splashpage' when they visit your blog, you could always use a jquery redirect script. Hope some of this helped!
Im sorry to say, with their existing theme options as of today, you cannot achieve this without horribly ruining your seo reputation.
I have tried many ways to do this, using tumblr php api and other,
This worked for me: I am using a page outside tumblr and loading the tagged posts via curl php calls.
It can be done via ajax but for SEO reasons I wanted to use php.
Here is the code:
$oath = 'xxx';
$blogName = 'yyy.tumblr.com';
$tag='tagname';
$apiLink = "http://api.tumblr.com/v2/blog/$blogName/posts/?api_key=$oath&tag=$tag";
// Initializing curl
$ch = curl_init( $apiLink );
// Configuring curl options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
);
// Setting curl options
curl_setopt_array( $ch, $options );
// Getting results
$result = curl_exec($ch); // Getting JSON result string
$data = json_decode($result);
$posts = $data->response->posts;
I realise this is old, but I've just had to do it, so here is my solution. At the end of the theme, in the script tags add:
{block:IndexPage}
$( ".the-posts" ).load( "tagged/home .the-posts article" );
{/block:IndexPage}
Where home is the tag you have given the posts you wish to see on the index page. This will basically load the correct articles into the posts div, replacing what it there. See the jquery man page: http://api.jquery.com/load/ for more info.