How to use Property Sets on Snippets in Revolution - modx-revolution

If I understand MODX Revolution correctly, I should be able to make a Property Set (Tools -> Property Sets) and apply it to an element as default properties. See rtfm.modx.com.
I have created a Property Set - 'tvsEnabled' - with the following values:
includeTVs: 1
tvPrefix: (empty string)
processTVs: 1
And then I call the following Snippet:
[[getResources#tvsEnabled? &parents=`8` &tpl=`TplArticle`]]
This returns nothing...

Firstly, please provide the code for TplArticle tpl, as there may be error in that tpl as well. The above code is perfectly correct.
Secondly, the tvPrefix parameter should be set properly. If you put an empty string, its no harm. But, try not overriding its default value. Now, if you have put an empty string, your tpl should access template variables according to the tvPrefix that you have provided, for e.g., [[+name]]. If you don't override its default value, you have to access template variables with the +tv. prefix, for e.g., [[+tv.name]].
If this doesn't work out, please do elaborate on the total task at hand and all the pieces of codes in relation to that, which you have written.

Related

Timeframe as a variable, which declaration type?

I am working on a MQL4 expert advisor. This advisor uses 2 separate
timeframes for its signals and entries/exits. Up until now I have used an "sinput" to allow the user to choose the desired timeframe for the higher timeframe indicators.
I would like to remove the option, and have the optimized pairs set automatically in my code. I am attempting to initiate a variable "IndicatorTF", and then later assign it a value of the desired timeframe.
Every other portion of my code runs just fine, however programmatically setting and changing timeframes is new to me.
If I try to initialize the variable "IndicatorHTF" globally and then actually set the value in "On Init" I get an error stating that I cannot change a constant. If, however, I set the "IndicatorHTF" variable directly in "On Init", just before it is actually used, I get a declaration error as I cant seem to find the correct type.
I realize its not a bool, int, double, or string, but I have no Idea what I should be using as a type.
What ive tried:
1)
//Globally
ENUM_TIMEFRAMES IndicatorHTF; //with sinput,bool,string,etc
int OnInit()
{
if(Period()==PERIOD_M1){resolution=PERIOD_M5;}
}
2)
int OnInit()
{
ENUM_TIMEFRAMES IndicatorHTF; //with sinput,bool,string,etc
if(Period()==PERIOD_M1){resolution=PERIOD_M5;}
}
Fixed the issue, it was simply a placement issue. By setting
if(Period()==PERIOD_M1){IndicatorHTF=PERIOD_M5;}
actually within my trade logic that used IndicatorHTF it was able to read and set the values correctly :)

Binding boolean (Property) to List operations in JavaFX

I found JavaFX to be suprisingly expressive after getting over the fact that I had to redeclare every field as property so I am a little stumped and would like to know if there is a better, more idomatic way of binding a boolean to some more complex operation like adding and removing style classes.
In this example I have a project that maybe valid or not and I want the font color of the tab to indicate which it is. I am doing this by adding and removing the error style class:
val errorSwitch = { valid : Boolean ->
logger.debug {"errorSwitcher: $valid"}
if( valid) tab.styleClass.remove("error")
else tab.styleClass.add("error")
Unit
}
product.isValid.onChange (errorSwitch)
errorSwitch(product.isValid.value)
What I don't like here is that I have to call the function once myself to start with because "onChange" obviously does not trigger unless the isValid actually changes. It's a small thing but I am wondering if there isn't a better way with bindings because thats what I want: the presence of the error class should be bound to "isValid"
In TornadoFX the best way to achieve this is to use the toggleClass function, which will automatically add or remove a given class based on a boolean observable value. Therefore you can simply say:
tab.toggleClass(Styles.error, product.isValid)
This example requires you to use the Type Safe CSS feature of TornadoFX. Read more about Type Safe CSS in the guide :)

Modifying the operating frequency (for 802.11ac) on ns-3

I am attempting to change the operating frequency to 300MHz (to simulate the working of 802.11af) but retain the overall PHY layer configuration of 802.11ac.
I have gone through earlier posts and realized that the SetFrequency() function (in the class YansWifiPhy) can be employed. However, when I implement the following statement ('wifi' is an object of the class WifiHelper)-
NetDeviceContainer staDevices = wifi.Install (phy, mac, wifiStaNodes);
I get an error since the object 'phy' is required to be of YansWifiPhyHelper datatype, not YansWifiPhy. However, I can't seem to change the frequency using the YansWifiPhyHelper class. How do I resolve this problem?
As you can see YansWifiPhy is a child class of WifiPhy. The typeId of WifiPhy has Frequency as an attribute. You can set this attribute using any to of the following way:
You can change the default value of ns3::WifiPhy::Frequency using the Config::SetDefault function. The documentation for the same can be found here.
Secondly you can use the Set function of YansWifiPhyHelper to set any attribute of YansWifiPhy (WifiPhy). You can find an example of this here. The only difference from the link will be that you need to change the attribute name to Frequency and change the value accordingly.
Please, let me know in case of any doubts or any of these don't work for you.

JavaFx Label text = variable

I have a JavaFX GUI in an fxml file with its controller class defined. I have two text items that I want in that GUI, one tied to a variable whose value does not change until the user reloads the screen, the other I would think needs to be a StringProperty as it shows the running total of a column in my TableView. Because of what they are, I'm trying to use Label instead of a TextField as their display control.
I liked Sebastian's answer to this problem here:
Displaying changing values in JavaFx Label
however, when I try to use it I get a compile error that says:
cannot find symbol
symbol: variable textProperty
location: variable salesNoLabel of type Label
I'm not sure what I'm doing wrong, but to start with, my label text is initially set in the fxml file, so in my controller I just have its fx:id substituted for "myLabel" listed in Sebastian's answer:
salesNoLabel.textProperty.bind(sn);
where salesNoLabel is the fx:id of the label and sn is a string variable.
Not sure if you need to see more of my code to help me with this problem, but thanks in advance for checking it out.
Sebastian's answer had a syntax error, I edited it to fix it.
You need to invoke the textProperty() method on the label:
salesNoLabel.textProperty().bind(sn);
Note the addition of parentheses after the textProperty identifier to invoke the method.

How do I access the Activerecord setter I overrode?

I want to use a custom setter to do some formatting of my fields. In irb if I test the setter like:
o.field_name = "4"
I see that my custom setter is being referred to. But with this it is not:
o[:field_name] = "4"
I understand that in the first case this is a function call and in the second case we are just setting the attribute directly. But I don't completely see how the attribute can be set without going through our custom setter, I thought that was the point.
But my main question is that if var holds my field_name, I don't see how to dynamically refer to a.var and have it be interpreted as a.field_name. All I see to do is a[var] and this bypasses my setter.
Try a.send(var) where var = 'field_name'
That's the equivalent of a.field_name
o[:field_name] is like read_attribute(:field_name), thus is just reads the value as you said. It can be quite important in virtual attributes in order to bypass the stack too deep error. If you do a[:var], you just get its value. A virtual attribute refers to an attribute, if you are setting its value to another variable, you just get its value, not the object.

Resources