Currently the code below will only show the HeroImage if one exists. If one doesn't exist, it doesn't show the other image blogImage. How can I change the code to show blogImage, if there is no HeroImage. Thanks
<img src="[[*HeroImage:isempty:then='[[*blogImage:phpthumbof=`w=1200&h=800`]] [[*]]':else='[[*HeroImage:phpthumbof=`w=1200&h=800`]] [[*]]']]" alt="[[*pagetitle]]" class="img-responsive"/>
Using the :default option should be enough:
[[*HeroImage:default=`[[*blogImage]]`:phpthumbof=`w=1200&h=800`]]
Ifempty and (default, empty, isempty) works like default value if input not specified else it returns the input value itself. So second else statement has no meaning and doesn't work.
For your purpose you can use "is" modifier like
[[*HeroImage:is=``:then=`[[*blogImage:phpthumbof=`w=1200&h=800`]]`:else=`[[*HeroImage:phpthumbof=`w=1200&h=800`]]`]]
And keep in mind using back-ticks for modx templating
I'd roll this a slightly different way, but it's likely the same result:
[[*HeroImage:neq=``:then=`[[*HeroImage:phpthumbof=`w=1200&h=800`]]`:else=`[[*blogImage:phpthumbof=`w=1200&h=800`]]`]]
Related
I am working on Verigy 93K test program and I have a logic that I would like to know if there's an equivalent code in Origen.
I am working on Verigy 93K test program and I have this logic (IF condition) that I need to insert in my flow.
Basically, I have a variable called 'INSERTION' and this will have different values like 'GCORR', 'VCORR' and others.
I would like to know if there's an equivalent code like this in Origen.
I attached a snapshot, hope that it can help clarify my question more.
In this logic, I would like to check the INSERTION value and if the value is not equal to GCORR or VCORR, the logic should pass, else, fail.
Here is the screenshot:
This pull-request adds an official API for this.
This example would be implemented as:
whenever_any ne(:INSERTION, 'GCORR'), ne(:INSERTION, 'VCORR') do
# Your tests in here
end
That would produce something logically equivalent and which can be re-targeted to other platforms.
If you don't care about that and want to produce exactly as you have it in the above example, then this should work too (where the OR is hard-coded for V93K syntax):
whenever ne(:INSERTION, 'GCORR|VCORR') do
# Your tests in here
end
Here is the preliminary documentation of this feature from the above PR - https://github.com/Origen-SDK/origen_testers/blob/66345c9422d9fa6b2577af20110259e45c2bdd26/templates/origen_guides/program/flowapi.md.erb#L71
I couldn't find api support on flow control or variable values beyond "if/unless_enable" support which can help check for 1 or zero. One way is to use render.
render 'if #INSERTION != "GCORR|VCORR" then'
render '{'
# your code for non-GCORR_VCORR flow
render "} \n else \n { \n } "
I'm trying to output a template variable inside the if statement in ModX, but it gives no output.
I have multiple pages with links to articles and the point is to only output template variable content on the first page but not the others.
// This gives no output:
[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=``]
// This outputs "yes" on the first page and "no" on others:
[[!#get.page:is=`1`:or:is=``:then=`yes`:else=`no`]]
I've even tried this, but it still does not give any output. I guess the problem is not about the output modifier:
[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=`[[*content]]`]
I'm using ModX Revo 2.7.0
Any help is appreciated, thanks in advance!
Actually in your case missing a double closing angle bracket "]]"
[[!#get.page:is=`1`:or:is=``:then=`[[*content]]`:else=``]]
The `or:is=` is matching against an empty state. Unless that is intentional you should be able to remove it. Also, the `:else=`` is the default state, so, you don't need that either.
The following should work and you'll have cleaner code:
[[!#get.page:is=`1`:then=`[[*content]]`]]
I try to learn MODX FormIt component usage (MODX revolution v.2.7.0, FormIt v. 4.1.1). Now I try to set validation rules for form field, such as "required, only numbers, greater than", meanwhile I want to use placeholder for minimal value. I call FormIt like this:
[[!FormIt?
&hooks=`openSession`
&redirectTo=`1`
&placeholderPrefix=``
&validate=`my_field:required:isNumber:minValue=`[[!+my_min_value]]``
]]
but I can input any number in 'my_field' field. If I use number for minValue instead of placeholder, all works fine. Placeholder is successfully resolving into number in the form below, too.
When I am wrong?
IIRC, you cannot use placeholders in the parameters.
Although, you should try with the following code, in case it is now supported in latest versions:
[[!FormIt?
&hooks=`openSession`
&redirectTo=`1`
&placeholderPrefix=``
&validate=`my_field:required:isNumber:minValue=^[[!+my_min_value]]^`
]]
OR
You could use custom validator, in which you should be able to use getPlaceholder to read your placeholder.
For more details on why use ^ instead of back-ticks, please see https://docs.modx.com/extras/revo/formit/formit.validators
I have a very simple if statement that is looking to see if $_FILES[] is set and if so create a variable. Here it is:
if(isset($_FILES['photo']['name'])){$image="yes";}
So if it finds the files is in fact set, give $image the value of yes. At the moment, regardless of if its set or not, the value is being passed to $image. Its driving me nuts. Doesnt matter if I drop the ['name'] part even. Ive been doing every incarnation of the if statement I can think of to make it behave but Im at a loss.
It turns out that checking to see if $_files isset will return a value in that even with no file being uploaded the array will contain information. If you were to do var_dump on $files['photos']['name'] you will see that the value for that bit of information is 0 and therefore when checking to see if its set you will get a positive response. This is how I overcame my problem:
$foo =$_FILES['photo']['name'];
$foopoo = $foo[0];
if (strlen($foopoo)>2){$image= "yes";}
I try to hide the getPage [[+pageNav]] Placeholder if there is no pagination. But I can't do the following.
[[!+pageNav:notempty=`<ul class="overview__pagination">[[!+pageNav]]</ul>`]]
Does someone know how I can hide the element with an apropriate output filter? (without own extra snippet). I also tried the following and some other (not likely to work variations).
[[!+pageNav:isnot=``:then=`<ul class="overview__pagination">[[!+pageNav]]</ul>`]]`
Are you calling that code in a chunk that is cached?
Otherwise i've experienced this aswell and it seems custom placeholders sometimes behave that way, it's probably due to the fact that they actually have some unprocessed value during the IF computation but when it's actually output you see nothing. Or that the value is somehow "null" instead of "" while modx output filter might do a strict comparison.
If you're not calling it in a cached chunk or part of code, i suggest first trying with another getPage placeholder such as pageCount or total.
Like:
[[!+pageCount:gt=`1`:then=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
If that still doesn't work, a last resort in the form of a simple snippet will always solve it, like:
[[!outputPagination? &total=`[[+total]]` &limit=`XX` &output=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
In snippet:
if ($total > $limit) {
return $output;
}
Shouldn't it be...
[[!+page.nav:notempty=`<ul class="overview__pagination">[[!+page.nav]]</ul>`]]
Well, there is a much more easier way to do it than in the first answer. It's like TheMistaC says, even if my answer is a lot easier:
[[!+page.nav:notempty=`
[[!+page.nav]]
`]]
I use it to display a list of articles with getResources, so I know this works fine.