Invenzzia »

Open Power Template 2.x family

PLEASE PROVIDE THE TEMPLATES AND/OR PHP CODE IN THE TASK DESCRIPTION (Not URL-s to them). THAT ALLOWS US TO REPRODUCE THE PROBLEM! OTHERWISE WE ARE NOT ABLE TO HELP YOU!

Remember to hide all the security-related pieces of code from the task description, like passwords, server paths etc. for your own safety. Once we close the task, we cannot edit it anymore!
Tasklist

FS#118 - Put a variable value or a default value

Attached to Project: Open Power Template
Opened by Damian Nowak (Nowaker) - Saturday, 12 September 2009, 18:12 GMT-7
Last edited by Zyx (Zyx) - Sunday, 13 September 2009, 01:01 GMT-7
Task Type Feature Request
Category Template syntax
Status Assigned
Assigned To Zyx (Zyx)
Operating System OS-independent
Severity Low
Priority Normal
Reported Version 2.0.1
Due in Version 2.1.0
Due Date Undecided
Percent Complete 0%
Votes 0
Private No

Details

Is:
~~~
<opt:if test="$myVar">
{$myVar}
<opt:else>
default
</opt:else>
</opt:if>
~~~

Could be:
~~~
<opt:var name="myVar">default</opt:var>
~~~

No default value:
~~~
<opt:var name="myVar" /> (the same as {$myVar})
~~~
This task depends upon

Comment by Zyx (Zyx) - Sunday, 13 September 2009, 00:53 GMT-7
This is already implemented, but as a function:

~~~~
<p>{firstof($myVar, 'Default value')}</p>
~~~~

You can use it to select the first non-empty value from the provided attributes. Another way is to use `opt:content` attribute. I'll add a page about it to the wiki, because I agree the "trick" could be confusing. However, I'll keep it open, because the idea of creating the tag version of `opt:content` seems quite nice.

Loading...