typoscript dynamic link parameter - typo3

i try to get a page title in a parameter for a link like:
index.php?id=1&mainsite=development
the "development" is the page title
i've try it with:
[EDIT]
50 = TEXT
50.value = get involved
50.typolink{
parameter = 28
parameter.data = #you need something else than the title here
additionalParams.dataWrap = &mainsite={GP:type}
additionalParams.if.isTrue.data = GP:type
useCacheHash = 1
ATagParams = class='btn btn-primary btn1'
}
from Add parameter to link in typoscript
This call is in an COA and the link should become different GET params with name &type=get_involved or &type=realize. i thought, i take the title or subtitle for that.
How can i realize dynamic params in Typoscript ?
Thanks,
ShaoKhan

50 = TEXT
50.value = get involved
50.typolink{
parameter.data = #you need something else than the title here
additionalParams.dataWrap = &mainsite={GP:mainsite}
additionalParams.if.isTrue.data = GP:mainsite
useCacheHash = 1
ATagParams = class='btn btn-primary btn1'
}
You can not link to the title directly, because TYPO3 uses the UID of a page to generate internal links. Any approach using a real page title for the link would result in an external URL, which would not give you the option of additionalParams.
So you will either need a PHP based function that generates the UID out of the title, or you must provide more than just the title within your GP vars.

my solution if anyone need it:
50 = TEXT
50.value = get involved
50.typolink{
parameter = 28
additionalParams.rawUrlEncode = 1
additionalParams.data = field:header
additionalParams.wrap = &type= |
ATagParams = class='btn btn-primary btn1'
}
it creates a link to page 28 and puts the GET param &type= at the end
the wrap contains the header of a part of the content
The link looks like this:
http://localhost/index.php?id=28&type=dread_disease
hope it'll help. _problem solved_

Related

TYPO3 RTE-Link with id of linked page as data-atribute or rel-tag?

I'm trying to add the special id of the linked page as an rel-attribute to each a-Tag of the RTE.
At the moment, the rel part is include in the link, but with "page:uid" it inserts the actual page ID and NOT the id of the linked page.
lib.parseFunc_RTE.tags.link {
typolink.parameter.append < lib.parseFunc.tags.link.typolink.parameter.append
typolink.ATagParams = rel={page:uid}
wrap < lib.parseFunc.tags.link.newWrap
}
For Example:
The site "Contact" has the ID-number 210 but at the moment, i'm on the "start" page with the id = 11.
Now I have a textlink at the page "start" to the "Contacts" page.
The HTML part looks as follows:
contact
But it should be like this
contact
Or even better like this (with special data-attribute)
contact
How can I get this?
Many thanks in advance.
What you try to do is a bit tricky in TypoScript, but not impossible. You have to work on the arguments of the pseudo <link> tag which look like 162 - some-class ... - 162 is the page-id in this example.
TypoScript
# Simulating some content
page = PAGE
page.10 = TEXT
page.10.value (
<link 162 - some-class>Some page</link>
)
page.10.parseFunc =< lib.parseFunc_RTE
# Adjusting parsing instructions for pseudo links
lib.parseFunc_RTE {
tags.link {
typolink.ATagParams.append = TEXT
typolink.ATagParams.append {
stdWrap {
# having all link settings "162 - some-class ..."
data = parameters:allParams
# split by whitespace
split.token.char = 32
# use first item
split.returnKey = 0
# enforce integer values
intval = 1
}
noTrimWrap = | data-relation="|"|
}
}
}
Generated markup
<p class="bodytext">
Some page
</p>

How to set TYPO3 7 metatags from TypoScript RECORDS?

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]

Build HMENU with Information from TCE

I have extended the TCA for every Backend-Page on the Page-Tree. One of the new Options is the "Page-Type", for example "PressPage". With this Extension, i have a new databasefield in the table "pages".
Now i would build an HMENU/TMENU with all pages, below this folder.
[...]
lib.MetaPressNavigation{
special = directory
special.value = ID_FROM_FOLDER_WITH_PAGETYPE_PRESSPAGE
[...]
But i have no idea to realize them with typoscript.
I hope anyone can help me.
Thanks.
EDIT:
Now - i have try it with an extended TCA. It's very easy for any User to make some configuration for this projectpage. The Users can set a value with an Checkbox in a special tab.
I have try to get the page out form the database, with this special config - any page have in the database on the column "tx_meta_pagetype the value 9. I need the UID from this page to build the META-Navigation. It will be full functional - when i give a hardcoded uid, but i need this dynamic.
This is my attemp, to get the UID from the database:
temp.MetaNavigationIds = CONTENT
temp.MetaNavigationIds{
table = pages
select.Where = tx_meta_pagetype = 9 #tx_meta_pagetype is set from the TCA
renderObj = TEXT
renderObj.field = uid
renderObj.stdWrap = |
}
lib.MetaNavigation = HMENU
lib.MetaNavigation{
special = directory
special.value < temp.MetaNavigationIds #the UID of configured page, that i need for the menu
1 = TMENU
1 {
wrap = <ul> | </ul>
NO{
wrapItemAndSub = <li> | </i>
wrapItemAndSub.insertData = 1
allStdWrap.insertData = 1
}
}
}
I have try a lot of database question with typoscript, but nothing works.
Be careful, special.value is not a content object but just a property. You are copying a content object (CONTENT) in its place. This does not work.
However it does have stdWrap. Therefore something like
special.value.stdWrap.cObject < temp.MetaNavigationIds
Should work out.
For renderObj.stdWrap = | enter renderObj.wrap = |, instead. Please mind the trailing comma. This will make sure that you actually get a comma separated list of uids. Otherwise your uids would be printed just after each other, thus forming one big number.
Please test each part individually before adding the components together. You should make sure that each pease returns the correct data, otherwise you will never get a working solution.
And of course select.Where must be select.where. Capitalization does matter.
Here is a working example for CONTENT:
page.10 = CONTENT
page.10 {
table = pages
select {
where = doktype = 199
recursive = 99
# Needs to be your root page uid
pidInList = 1
}
renderObj = TEXT
renderObj.field = uid
renderObj.wrap = |,
}
If you are using TYPO3 6.2, I would recommend to use the new category system. You can create different categories in the TYPO3 backend and assign those categories to your pages.
With this, you can create a HMENU/TMENU like shown below:
20 = HMENU
20 {
special = categories
special.value = 1,2
1 = TMENU
1.NO {
...
}
}
If you do not use TYPO3 6.2 or do not want to use the category system, you can use a userfunction to return the pages which matches your "Page-Type".
HMENU/TMENU TypoScript will be like shown below.
lib.leftmenu.20 = HMENU
lib.leftmenu.20.special = userfunction
lib.leftmenu.20.special.userFunc = user_myspecialmenu_pi1->getPressPages
The TypoScript above is just an example, and you need to code the userfunction your own.
A detailed reference of the special property userfunction is available here and a example can be found here.

TYPO3: how to include other columns in section index?

I have a website with two columns (colPos = 0 and colPos = 2). Haw can I include headers from column 2 into the section index? The default behavior is to include only headers from column 0.
More specifically, here is the TypoScript I use to generate the menu:
lib.menupage = HMENU
lib.menupage {
1 = TMENU
1 {
wrap = <ul> | </ul>
NO.wrapItemAndSub = <li> | </li>
sectionIndex = 1
}
}
I'm using TYPO3 6.0.
i guess you are searching for
lib.menupage.1.sectionIndex.useColPos = -1
(But this seems to be only available in TYPO3 6.0)
As a workaround it should be possible to do it on your own. Render a normal menu, but override (allWrap.cObject should do the job) the link with an CONTENT Object, which retrieves all headers from tt_content of that page. Here is some pseudo-code which help to explain how i would try to solve that problem. This code will not work, just show the principle:
lib.menupage = HMENU
lib.menupage {
1 = TMENU
1 {
wrap = <ul> | </ul>
NO.wrapItemAndSub = <li> | </li>
# pgampe suggested to use: stdWrap2.append instead of allWrap.cObject. My intention
# was to override the original link at all. But you should be able to play with
# the different stdWrap functions to get the best solution
# as far as i remember, allWrap will be wrapped by "wrapItemAndSub"
NO.allWrap.cObject = CONTENT
NO.allWrap.cObject {
table = tt_content
select {
# the uid is the id of the page where we need the content from
pidInList.field = uid
orderBy = colPos, sorting
}
# inside the renderobj we get the elements which are retrieved by CONTENT
renderObj = TEXT
renderObj {
field = header
typolink.parameter.field = pid
typolink.section.field = uid
required = 1
wrap = <span class="inside-li">|</span>
}
}
}
}
You are most likely looking for the section index function in the menu content object.
The rendering is defined in tt_content.menu.20.3.stdWrap.prepend.20 = CONTENT. You can use the TSOB (TypoScript Object Browser) to investigate the relevant typoscript setup.
You can adjust it to your needs like any CONTENT object in TYPO3. However it should already select any column (at least in 6.0).

Illustrate content from FCE in another way

I have some FCEs which are working fine. Now I want to display the data for another render type and I have to change from div to ul. Is there a way to extract the data fields with Typoscript? Currently the FCEs are included as Page-Content Elements in another template. The data processing contains the following TS Code
10= RECORDS
10.source.current=1
10.tables = tt_content
10.wrap = <!--TYPO3SEARCH_begin--> | <!--TYPO3SEARCH_end-->
#ggzone:
I tried this:
10 = COA
10 {
10 = TEXT
10 {
current = 1
typolink.parameter.field = field_link_text
required = 1
wrap = <h3>|</h3>
}
}
But I only get <h3>39,40,57</h3>. That are the IDs from the FCEs. How do I get the field value?
ofcourse... this is an example how to render a FCE... u can also use a Typoscript select in there from tt_content. there are many snippets outside. for example just replace your snippet with this one just to see if it works. dont forget to edit the "field_yourfieldname" to your field_xxxx
10 = COA
10 {
10 = TEXT
10 {
current = 1
typolink.parameter.field = field_yourfieldname
required = 1
wrap = <h3>|</h3>
}
}
typolink is not the only where you can use .field as typolinks uses the ID to link to a page (&id=123) you will get it. you can also use value.field or stdWrap.field.
heres another example which should work:
10 = HTML
10.value.field = field_yourfieldname
take a look aroun in google.. its not easy to find some snippets but also not that hard. as i use this not often i also need to take a look around everytime