Computer Magic Logo
Add parameters to the Macro

Saturday, August 8, 2015

Published by Aristotelis Pitaridis

Parameters act as properties to a control. We change the values of a parameter and the control changes the final output depending on the values we used. Let’s try to create two parameters. The first parameter will be used in order to change the title and the second in order to change the paragraph tag.

We select the MyFirstMacro node from the node Macros of the Developer section.

The Macro properties will appear on the Screen. We click on the Parameters tab.

The form which allow us to create new parameters will appear on the screen.

For each parameter we need three information. We need the Alias name which will be used in code for accessing the value, the name of the parameter which will be a friendly name and the data type which will be used in order to store the information.

Let’s create one parameter for the title. We give the alias name title, the name Title and we select the type Textbox.

When we finish with the values we click the Add button which is on the right side of the form in order to add the parameter.

The same way we add a Textarea parameter for the Description and we click the Add button.

When we finish we click the Save button which is located at the upper right corner of the screen.

Let’s update our partial view so that it will display the parameters that we defined. We click the MyFirstMacro Partial View from the "Partial View Macro Files" node. We change the contents of the partial view so that it will contain the new parameters.

We open a Template and display its contents to the Template editor in order to insert the Macro. We delete the previous inserted Macro so that we will add it with the parameters. We put the cursor at the position that we want to add the Macro and we click the "Insert Macro" button.

The insert macro panel will appear on the screen with a drop down list box which will allow us to select the macro.

We expand the drop down list and the list with the available Macros will appear. We click on the Macro MyFirstMacro.

The parameters panel will appear on the screen allowing us to type the values we want.

When we finish we click the Select button which is located at the lower right corner of the screen in order to insert the Macro in our Template.

The Back Office has inserted the Macro and added all the required information so that the system will display the values that we defined.

Let’s see now the page in order to see what the final output of the Macro is.