Anybody here who knows how to write this TS condition in the new symfony expression syntax?
[globalVar = TSFE:sys_page|versioningWorkspaceId = 1]
Or is there any other way to find out if one is viewing a workspace?
Thanks in advance!
the desired syntax is:
[getTSFE().sys_page.versioningWorkspaceId == '1']
As a rule of thumb,
Arrays should be written with brackets,
Objects are written with points.
Related
How can I write this old style typoscript condition in Symfony Expression language?
[globalVar = GP:tx_myext_myplugin|bla > 0]
Perhaps something like
[request.getQueryParams()['tx_myext_myplugin[bla]'] > 0]
but that is obvious not working.
[(request.getQueryParams()['tx_myext_myplugin'])['bla'] > 0]
In case it is generating an error inside log then you need to check like this.. (i.e. Unable to get an item on a non-array)
[request.getQueryParams() and
request.getQueryParams()['tx_myext_myplugin'] and
request.getQueryParams()['tx_myext_myplugin']['bla'] > 0]
//Typoscript Code
[end]
&& can also be used as conditional operator here
The old style TypoScript condition [globalVar = GP:tx_myext_myplugin|bla > 0] can be written with new condition syntax like [traverse(request.getQueryParams(), 'tx_myext_myplugin/bla') > 0].
Use traverse in combination with getQueryParams to avoid errors in case a key in the parameter array is not defined.
Output: 2015-01-20 03:52:19
Need 01.20.2015 + 1 week = 01.27.2015
I curently have {$order[orders].invoice_date|date_format:"%d.%m.%Y"}
But how to add week + 1?
So, I need to add 1 week and then formating this.
But the date isn't in the timestap format.
Smarty version: 3.1.
I can use only smarty logic, not PHP.
How to achieve this?
You don't need a plugin to work this out. It can be solved with a combination of cat and date_format.
Since date_format is a wrapper to PHPs strftime(), you can use the conversion specifiers available in strftime() - and that is what I used tackle the issue at hand.
Try this:
{$order[orders].invoice_date|cat:' +1 week'|date_format:"%d.%m.%Y"}
I've used Smarty version 3.1.17 to recreate your problem. The solution is based on the assumption that the value in your variable $order[orders].invoice_date is a string 2015-01-20 03:52:19.
You can create a smarty plugin, something like this one to suit your needs. http://smarty.incutio.com/?page=AlternativeDateModifierPlugin
You shouldn't be doing this logic in smarty at all. This type of thing should be done in the php code - assign two date values to two separate smarty variables (one with the 1 week added), and use the appropriate one in the appropriate place in your template (applying the appropriate date_format as required).
edit: I know you've said you want to do this using smarty syntax - I'm just pointing out that trying to do this type of manipulation in smarty is not what the template language is designed for. If you only have access to the smarty .tpl files, you might try using the {php} tag to put your php logic in the .tpl file.
In Crystal 11, does the possibility exist to create a statement that would solve this issue I am faced with, using a formula field...
look at {fieldA} if there is a value listed, this should be the result
but if {fieldA} is blank then refer to {fieldB} then use this as the result
Any advice or example statements for me to look at would be greatly appreciated
Something like this:
if {fieldA} = "" then {fieldB}
else {fieldA}
Assuming you want to treat NULL values as blanks, then this is very straightforward. Simply create a formula field with this:
if {fieldA} > "" then {fieldA}
else {fieldB}
HOWEVER!! For this to work for NULL values of{fieldA} you MUST toggle to "Default Values for NULL option.
Is it possible in Jasper Reports to conditionally set a textbox style? If yes, how?
Please note that I'm aware of conditional styles, but I do not need a style which varies on a condition, but set the proper style using a different condition for each textbox (of course I could create a conditional style for each textbox, but that would be a real PITA...).
I'm using Jasper Reports 3.7.6 and the Jasper Studio Eclipse plugin.
Thanks
Use case example pseudocode:
bean1 {
f1
f2
}
bean2 {
cond1
cond2
}
<textbox1 style="(bean2.cond1 ? style1 : style2)">
bean1.f1
</textbox1>
<textbox2 style="(bean2.cond2 ? style1 : style2)">
bean1.f2
</textbox2>
Unfortunately you can't define a generic style. See page 135 of the iReport Ultimate Guide:
http://community.jaspersoft.com/documentation/ireport-ultimate-guide:
Please note that the conditions cannot be generic,
for instance, you cannot set a condition like “if the number is positive” or “if the string is
null
.” You must be very specific,
specifying, for example, that a
particular value (field, parameter, variable or
any expression involving them) must be positive
or
null, and so on.
Answering myself: it turns out that it is not possible to set conditional style the way I needed. I ended up with duplicating each text fields (a copy for each style), then setting the visibility upon the condition. Boring and time consuming, but it works.
Using the jquery-tmpl, I want to stripe presentation of the rows by adding a class to every second one, so from data ['Cat','Dog','Horse','Noddy'] it generates:
<li>Cat</li>
<li class="odd">Dog</li>
<li>Horse</li>
<li class="odd">Noddy</li>
The solutions suggested here looked like the start of something that could be further refined for easy digestion by us noddy's.
Never mind. Overcomplicating things as usual...
Just follow it up with the :odd selector with addClass...
$('#template').tmpl(data).appendTo('#list')
$("#list li:odd").addClass('odd')
Just found the solution after few trial and errors. You can use the {{= }} tag for evaluating expression:
{{each(i) Animals}}<li class="{{= i % 2 ? 'even' : 'odd'}}">...</li>{{/each}}
Of course you can modify it to suit your needs exactly - you can put the class inside and print empty value for odd or even.
Another solution would be to use a function (there is example of this in the jquery tmpl docs), but it is ugly.
#John Mee, I don't think you are overcomplicating.
Imho the template is the place where the addition of the odd-Class should take place. Logic and performance wise.
Here is a patch for having the index inside a nested template. If you like to have an additional $odd property it could be easily extended as follows:
jQuery.map( data, function( dataItem, index ) {
if(dataItem){
dataItem.$index = index;
dataItem.$odd = index % 2 === 1;
}