Reputation: 1028
My goal is quite simple. If a certain GET parameter is not empty in the URL of the present page I'd like to inject some css to it.
In the example bellow I'd like to hide everything (just for example proposes) if the tx_multishop_pi1[page_section]
exists in the URL.
page{
headerData.960= TEXT
headerData.960.data = GP:tx_multishop_pi1|page_section
headerData.960.required = 1
headerData.960.value(
<style type="text/css">
body{
display:none !important;
}
</style>
)
}
But this isn't working. I could try [globalString = GP:tx_multishop_pi1|page_section = somehting]
but I don't want that. I want to inject css if the tx_multishop_pi1[page_section]
var exists (no meter its value)
Upvotes: 0
Views: 394
Reputation: 671
this can be done by using globalString
condition and if.isTrue.data
[globalString = GP:tx_multishop_pi1|page_section > 0]
page.headerData.960 = TEXT
page.headerData.960 {
value (
<style>
body{
display:none !important;
}
</style>
)
if.isTrue.data = GP:tx_multishop_pi1|page_section
}
[end]
Upvotes: 2
Reputation: 55798
You can use userFunc
condition (on the bottom of the TSref Conditions) to perform (almost) any comparison.
The most important thing to remember is that this function must to begin with user_
prefix, there are some old docs, which doesn't mention that or gives wrong samples. Here's a sample for you (add it to localconf.php
)
function user_multishopSectionExists() {
$gp = t3lib_div::_GP('tx_multishop_pi1');
return (is_array($gp) && array_key_exists('page_section', $gp)) ? true : false;
}
So you can use it in the TS setup field:
[userFunc = user_multishopSectionExists()]
page.headerData.960= TEXT
page.headerData.960.value(
// etc...
)
[end]
Of course it is better idea to write general matcher ie. something like:
[userFunc = user_paramExists("tx_multishop_pi1|page_section")]
Upvotes: 0