I would like to add a data attribute to the link handler on my website.
I have the following in my setup.ts:
config.recordLinks.test {
forceLink = 0
typolink {
parameter = #test
ATagParams = data-toggle="hover"
}
}
However, the data attribute does not arrive in the source code.
I have no more ideas why this could be. Everything else that is interpreted from https://docs.typo3.org/m/typo3/reference-coreapi/8.7/en-us/ApiOverview/LinkBrowser/Linkhandler/Index.html
Anyone have an idea?
Related
I've created a small application form for my website. Everything works fine.
In the plugin settings there is a field called "Bodytext for Email to Receiver". This is the the mail I get, everytime somebody fills out an application form. It looks like this right now:
New application arrived!
{powermail_all}
Is it possible to get the Page UID from the application form into a variable to put it in there?
The only solutions I've found need TypoScript. Is there any other way?
The solution with typoscript should be (according to manual):
use in template:
{f:cObject(typoscriptObjectPath:'lib.pageuid')}
define the typoscript:
lib.pageuid = TEXT
lib.pageuid.data = page:uid
I'm not sure about an additional variable for {powermail_all} as I'm not familiar with the extension.
If I understand the manual correctly this might be possible with :
plugin.tx_powermail {
settings {
setup {
manipulateVariablesInPowermailAllMarker {
// possible sections (define for each, where you need it):
// confirmationPage, submitPage, receiverMail, senderMail, optinMail
submitPage {
pageUid = TEXT
pageUid.data = page:uid
}
senderMail {
pageUid = TEXT
pageUid.data = page:uid
}
}
}
}
}
I'm trying to override the page.meta.og:title in TYPO3 7.5 with a TypoScript RECORDS object.
The following TypoScript snippet does not seem to work unfortunately:
[globalVar = GP:tx_myext_pi1|article > 0]
temp.newsTitle = RECORDS
temp.newsTitle {
dontCheckPid = 1
tables = tx_myext_domain_model_article
source.data = GP:tx_myext_pi1|article
source.intval = 1
conf.tx_myext_domain_model_article = TEXT
conf.tx_myext_domain_model_article {
stdWrap.field = title
stdWrap.wrap = |
}
}
# Overrides the template pageTitle
page.10.variables.pageTitle >
page.10.variables.pageTitle < temp.newsTitle
# Overrides the meta og:title
page.meta.og:title >
page.meta.og:title < temp.newsTitle
[global]
I get:
<meta name="og:title" content="RECORDS">
While the override of the page title works for me.
Are there any ways to achieve this with TypoScript?
RECORDS only works within a cObject.
https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Records/Index.html
[globalVar = GP:tx_myext_pi1|article > 0]
page.meta{
og:title {
attribute = property
stdWrap.cObject = RECORDS
stdWrap.cObject {
source = {GP:tx_myext_pi1|article}
source.insertData = 1
tables = tx_myext_domain_model_article
conf.tx_myext_domain_model_article= TEXT
conf.tx_myext_domain_model_article.field = title
}
}
[global]
While it's your ext what prevents you from adding it directly within action instead of manipulating with some weird TS? ;)
public function showAction($article) {
$ogTitle = trim(htmlentities($article->getTitle()));
$GLOBALS['TSFE']->getPageRenderer()->addMetaTag('<meta name="og:title" content="' . $ogTitle . '">');
// ... rest of action
}
Also take a look to Georg Ringer's News extension to see how he uses metaTagViewHeplper (actually he's doing the same but in VH) - you can use it to collect other og tags on the view like og:image and others.
Edit:
(More about preventing duplicated entries)
Keep in mind that duplicated meta combinations it's not a bug, it's a feature according to OGP Arrays spec ;) Actually fact that you can not declare two same meta tags with TypoScript is a bug, reason? TypoScript is not a programming language, it's just configuration table (array to be strict). As we know in PHP in associative array later key overrides earlier. While we're in topic of og:* metas we need to remember that sometimes they are repeated per page and it's perfectly valid, i.e: og:image.
You as a programmer has much more power within your action than in TS, even if you are using some ready-to-use ext which fills og:title from the pages records, nothing prevents you from discarding it with ... simple trick in TS, in your TS add a condition:
[globalVar = GP:tx_myext_pi1|article > 0]
page.meta.og:title >
[end]
and then make sure that you're adding it in your showAction as showed at the beginning.
Finally this way you do not need to make expensive lookup from TS site for each model that has a single view (believe me I know what that means)
BTW, I agree that there should be solid API for this, but I wrote some ext for one of my project for these things, that was matter of hours not even days, if I'll find it, I'll publish it to TER.
I was to quick with posting my question :)
It could be achieved by using the register, here is a example:
[globalVar = GP:tx_myext_pi1|article > 0]
page.9 = LOAD_REGISTER
page.9 {
newsTitle.cObject = RECORDS
newsTitle.cObject {
dontCheckPid = 1
tables = tx_myext_domain_model_article
source.data = GP:tx_myext_pi1|article
source.intval = 1
conf.tx_myext_domain_model_article = TEXT
conf.tx_myext_domain_model_article {
stdWrap.field = title
stdWrap.wrap = |
}
}
}
page.10.variables.pageTitle >
page.10.variables.pageTitle = TEXT
page.10.variables.pageTitle {
data = register:newsTitle
}
page.meta.og:title >
page.meta.og:title {
attribute = property
override.data = register:newsTitle
}
[global]
I'm not sure if I used the correct terms :D
Let's imagine that my backend-layout looks like this:
backend_layout {
colCount = 1
rowCount = 1
rows {
1 {
columns {
1 {
name = Baguette
colPos = 0
}
}
}
}
}
I'm looking for a TypoScript which looks kinda like this:
[...]
variables {
title < ****the stuff i'm looking for***
title.select.where = colPos = 0
}
The script should automatically take the name of my backend-column ("Baguette") and save it into the "title"-variable.
Then i can simply add <f:format.raw> {title} </f:format.raw> in my template to output it in the frontend.
Does something like this exist?
Btw: It's necessary to be able to select the colPos since I'm having many columns with many titles to output.
This does not exist. The titles are only known to the backend and are not available in the frontend context.
Actually the frontend does not know anything about the backend grid. All you have in the frontend, is the column number.
I'm using the extension seo_dynamic_tag, which is a fantastic plugin for TYPO3 SEO purposes.
It uses registers to store the generated meta description and keywords. Later on in the script, the page metadata is filled in from these registers:
page {
meta {
description {
field >
data = register:description
}
keywords {
field >
data = register:keywordss
}
}
1000 < temp.seo
}
So far it works like charm.
But in addition I'd like to display a TEXT object on the page with the meta description on the bottom. The text should read the meta description and some other stuff. That's where I need your help.
I tried to do the "magic" like this:
temp.description = COA
temp.description {
10 = TEXT
10.value = Meta description: {register:description}
stdWrap.insertData = 1
}
lib.footer < temp.description
This simply does not work. If I want to display something else, for example {page:title} or {date:y-m-d}, data insertion works. For register:xxx it doesn't.
I already spent lots of hours to google out my desired solution, but no success :(
Do you have any idea what I'm missing here?
I'm using TYPO3 4.5.3 (I know I should update ;)).
Many thanks in advance for your help! :)
Your stdWrap.insertData = 1 is applied to your COA-object, and not to your TEXT-object. You can instead set 10.insertData = 1 or just write the following:
10 = TEXT
10.data = register:description
Is it possible to auto generate a mixed string of digits and letters by TypoScript, e.g. 12A54 or something similar?
I'd prefer a userFunc to a php include script. For example, you can pass parameters to a user function.
Typoscript:
includeLibs.generateInvoiceNo= fileadmin/scripts/generateInvoiceNo.php
temp.invoiceNo = USER
temp.invoiceNo {
userFunc =user_generateInvoiceNo->main
}
PHP:
fileadmin/scripts/generateInvoiceNo.php
<?
class user_generateInvoiceNo {
var $cObj;// The backReference to the mother cObj object set at call time
/**
* Call it from a USER cObject with 'userFunc = user_generateInvoiceNo->main'
*/
function main($content,$conf){
$length = 6;
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$number=substr(str_shuffle($chars),0,$length);
return $number;
}
}
?>
Credits:
This php script
TYPO3 Wizard on userFunc
As already mentioned, there is no such functionality in Typoscript and so the preferred method is to use some simle PHP function as suggested in other answers.
However, there is a cheat and that would be to use MySQL. Mind you, that it's a solution only if you absolutely cannot (for a reason that I really cannot think of) write a piece of custom PHP. Take it rather as an academic answer than a practical one.
temp.random = CONTENT
temp.random {
table = tt_content
select {
pidInList = 1
recursive = 99
max = 1
selectFields = SUBSTRING(MD5(RAND()) FROM 1 FOR 6) AS random_string
}
renderObj = TEXT
renderObj {
field = random_string
case = upper
}
}
NOTES:
pidInList must point to an existing page.
The MySQL command is really just an example as the string would never contain letters G-Z. I'm sure it's possible to come up with a better string generated by MySQL.
Patching TYPO3 sources for such easy tasks is wrong idea. After the next source upgrade you'll lose your changes.
Instead it's better to include an easy PHP script where you can render what you need check TSREF