Is there a way to transform a variable from a particular template into a global one to be used in another template?
Example:
neworder.twig Template
Variable -> {{order ['id']}}
orderlist.twig Template
I would like to use the same {{order ['id']}} variable, which is assigned only to the Template neworder.twig
If I try to use it in another Template like the example:
<span href = "/ orders? id = {{order ['id']}}"> {{order ['id']}} </span>
I have no return on value.
It's possible?
Thank you!
Related
Just a quick question to understand whats the best way to use this. To fetch values off "locals" in terraform do i use lookup(local.this) or local.this or example below i got:
locals {
array = {"this" = data.something.output, "this02" = data.something.output }
}
You can reference each declaration within a locals block just as you would a normal variable, but as local.name instead of var.name.
So for your example you could use lookup(local.array,"this","defaultvalue"), or any of the other ways to access a map variable.
I've been trying to use a common property file in Jenkins which will have details of multiple servers. Based on the selection in Jenkins(By selecting "Build with parameters"), corresponding server details need to be obtained from the property file. For this, I need to access a value of variable created by value of another variable. Is this supported in groovy?
I have defined the properties in a property file and the sample values are like
PROD_SERVERNAME = sampleprodserver;
DEV_SERVERNAME = sampledevserver;
def environment = "PROD"; // this will be given as a parameter
def servername = environment + "_SERVERNAME";
def Propertyfile = readProperties file:propertyfile;
def server = Propertyfile.servername
I expect the value of server should be sampleprodserver but the value i'm getting is null.
Any help would be highly appreciated.
the code
Propertyfile.servername
tries to get property with name servername from Propertyfile variable
and to get the property value by variable value use one of:
Propertyfile.getProperty(servername)
//or
Propertyfile[servername]
I'm writing a puppet code and need to point to a variable with the information of others.... to make it clear here is the example:
These are the variables with the information:
Array $users_ap1_dev = ['userdev1,userdev2'],
Array $users_ap2_prd = ['userprd1,userprd2'],
but ap1 and ap2 values are store in a fact calles main_app and dev and prd values are store in a fact called env.
I want to retrieve the info and create the user based on the fact information, something like
$dmz_users.each | String $user |{
user { $user:
ensure => 'present',
}
So, how can i put the content of $users_ap1_dev into dmz_users, replacing ap1 and dev with the one store in the fact?
something like?:
Array $dmz_user = "${users_${main_app}_${env}}"
Thanks a lot in advance for the help!
I found the answer, the function: getvar()
It allows you to create a variable and put his content into another...
How to use it:
$dmz_users = getvar("users_${main_app}_${env}")
So let's says $main_app = web and '$env = prod', it will take this two values and will make '$dmz_users = $users_web_prod`
I have this code in .vm file
<script...>
.....
var attr = attr0[i].id;
</script....>
#set($attr1 = $request.getParameter("attr"))
$attr1
How to get the jquery attribute (which is clientside) to velocity template variable which is serverside?
As I suggested in my comment you can use a parameter, something like this:
In your template get the entire current URL (URL + parameter)
Check for your parameter (es. attr)
If ther is the attr parameter and it has a value do something in your template
In your script create a variable with your current URL and append your parameter to it (es. var url = {$currentURL} + '?attr=attrValue')
Now you have just to call this URL.
If we want to hide the DisplayName property of an InputField, we can override the InputField's default template in our theme. That works. That said, is there a way to use placement.info to do the same?
The following works but we would rather use placement.info for a more concise solution.
The Default InputField template.
#using Orchard.Fields.Settings;
#using Orchard.Utility.Extensions;
#{
string value = (string)Model.ContentField.Value;
if (!string.IsNullOrEmpty(value)) {
string name = Model.ContentField.DisplayName;
<p class="text-field">#T(name): #value</p>
}
}
Our Theme's InputField template.
#using Orchard.Fields.Settings;
#using Orchard.Utility.Extensions;
#{
string value = (string)Model.ContentField.Value;
if (!string.IsNullOrEmpty(value)) {
<p class="text-field">#value</p>
}
}
You've already found the standard way of modifying the rendering of the field. Note that you may use alternates such as the one that includes the name of the field, if you only want to target the rendering of particular instances. Placement probably won't be of much help here, except if you need to introduce additional alternates based on a placement match, but in any case, you'll have to use a modified template. The reason why placement can't be used here is that the label is not a content shape in itself and as such can't be targeted by placement.