Issue in accessing package variable in Dreamweaver Template - tridion

I am facing a issue in accessing a package variable in DWT of Page Template.
I have a compound page template with 4 TBB's as follows:
1) Constant TBB - This TBB reads all values of a component(Embedded multivalued component) as key-value pairs and pushes them to a package.
E.g :
Item item = this._package.CreateStringItem(contentType, "test");
this._package.PushItem("key", item);
2) C# DLL of Page Template - This contains the logic of Page Template
3) DWT of Page Template - All package variables are outputted here.
4) Default Finish Actions
The issue I am facing is as follows:
In my DWT ,I want to compare the Metadata of Component template with the package variable set in Constant TBB.
The syntax I am using is :
<!-- TemplateBeginIf cond="ComponentTemplate.Metadata.section_name = key" -->
where key is the package name set in constant TBB having value "test"
But somehow this package variable "key" is giving a value of 0 and not test.
Can someone let me know where exactly I am going wrong.

You should specify the type of item that you're adding to the package by replacing:
Item item = this._package.CreateStringItem(contentType, "test");
with
Item item = this._package.CreateStringItem(contentType.Text, "test");
You should also confirm that the variable is being passed properly to DWT by using
##test##
outside of the condition. This will show the value that you're comparing it to.

Please check following.
Check if there more than one variable in a package with "Key" name.
check if you verifying at correct place in package.

Related

Ignition Dynamic page creation binding tags to UDT

New to Ignition, I would like to understand how to dynamically create windows pages containing templates binded to UDTs.
I created a Template named TGBT having 4 parameters:
-DeviceName (string)
-TagBlock (string)
-TagOffset (string)
-TgbtNr (TGBT, drop target)
I created a UDT named TGBT with the same Data Type Parameters
and added in the data type structure new OPC using OPC Item Path [{DeviceName}]{TagBlock},I{TagOffset}
Then I created instance of UDT with add hoc values:
This works fine when I create the page using the Ignition Designer
I created a script that read a CSV file (will be database at the end) and creates UDT instances accordingly:
It works fine, I can see OPC values updated in the tag browser, with the expected OPC Item Path.
I understood Template canvas are the proposed way and populated the Templates dataset.
The script populates the template with provided parameters eg:
{"DeviceName":Elec,"TagBlock":DB200,"TagOffset":48}
The Templates instances are correctly placed in the Template canvas, but I should be wrong in parameters as the Template fields, labels (...) are not updated accordingly.
Have someone tried this, could help me?
Xavier
Also check out this forum thread to generate templates on a container without canvas: https://forum.inductiveautomation.com/t/dynamically-add-component-to-root-container/12735/11

How add a plugin with data to a page using the add_plugin (API)?

i'm trying to add a plugin in a placeholder of a page when i save a model. But i don't know how to pass the parameter "data" to add_plugin() function of the API.
This is how i'm calling the function
page = create_page(self.title, 'page.html', 'es', parent=query_pages[0])
placeholder = page.placeholders.get(slot='News Header')
add_plugin(placeholder, 'ArticlePluginPublisher', 'es', **query_art[0].article)
And when i call add_plugin appears the next error
add_plugin() argument after ** must be a mapping, not Article
Did you check the docs? **query_art[0].article doesn't match the expected arguments as it's an instance;
placeholder (cms.models.placeholdermodel.Placeholder instance) – Placeholder to add the plugin to
plugin_type (string or cms.plugin_base.CMSPluginBase sub-class, must be a valid plugin) – What type of plugin to add
language (string) – Language code for this plugin, must be in LANGUAGES
position (string) – Position to add this plugin to the placeholder, must be a valid django-mptt position
target – Parent plugin. Must be plugin instance
data (kwargs) – Data for the plugin type instance
Data is expected to be something like a dictionary, or something that supports the ** unpacking syntax;
add_plugin(placeholder, 'ArticlePluginPublisher', 'es', **{'article': query_art[0].article})
Check out this example of data or kwargs in a function call;
https://stackoverflow.com/a/1769475/1199464

Adding fields dynamically to Share form

I want to add a text field for each file that is added to the attached package items in alfresco to write notes regarding each file, is it possible to do?
I have implemented something that could be reused for your use case.
You can define a property with multiple values that will contain the list of notes associated with each attachment.
There is a simple trick to post a property with multiple values: add "[]" to the name of the property. For example:
<input id="template_x002e_edit-metadata_x002e_edit-metadata_x0023_default_prop_someco_notes_0"
name="prop_someco_notes[]"
tabindex="0"
type="text"
value="Meeting minutes"
title="Notes"
noderef="workflow://...."
>
<input id="template_x002e_edit-metadata_x002e_edit-metadata_x0023_default_prop_someco_notes_1"
name="prop_someco_notes[]"
tabindex="1"
type="text"
value="Meeting minutes"
title="Notes"
noderef="workflow://...."
>
As you can see, the name of the input ends with []. Both input textfields have the same name.
The Alfresco Form Engine will consider these two inputs as the value for the property with multiple values: "someco:notes".
The bigger problem is that you need to generate this html with some smart javascript and free marker template.
You can write a custom free marker template to render the initial html: if a user opens a task on which documents have been already attached, you will need to generate the list of inputs using a custom control (you can of course start from textfield.ftl).
It won't be easy to generate the initial list because unfortunately Alfresco returns the list of values as a single comma separated value.
You can customise the webscript that injects the model in the free marker template "org.alfresco.web.scripts.forms.FormUIGet" to pass an array instead of a csv.
A quicker and dirtier solution is to split the csv value. In share-config-custom.xml, you can specify what textfield.ftl show use as a separator instead of the comma.
When a user adds/remove elements from the package, you can intercept the update and add/remove the correspondent note. Notice that I have added the filed "noderef" to each input so it is possible to know the relation between the notes and the nodes in the package.
UPDATE:
For the associations (used for example to define the package in a workflow task), Share uses a javascript library called "object finder" (or "object picker"). This library fires an event called "formValueChanged" that you can intercept:
YAHOO.Bubbling.fire("formValueChanged",
{
eventGroup: this,
addedItems: addedItems,
removedItems: removedItems,
selectedItems: selectedItems,
selectedItemsMetaData: Alfresco.util.deepCopy(this.selectedItems)
});

Outputing Drupal Webform Values to Highrise

I am integrating Drupal Webform with the CRM Highrise - I'm using the Highrise Drupal module (https://drupal.org/project/highrise) to create some mapping - however I want to extend the module to pass additional form values to the "background" field designated within Highrise, the issue I'm running into is that rather than passing the form value of say "Birthday Party" it's simply returning "array" in Highrise, below is the code I have right now:
//initial variable declaration
$form['#get_eventtype'] = drupal_render($event_type);
//making the call to post to Highrise
case 4:
$background = $form_state['values']['submitted'][$row['cid']];
$background .= $form['#get_eventtype'];
$new_person->setBackground($background);
break;
Have you dumped the value in $background after you retrieve it from the form? It is going to be an array and your value will be in one of the array elements. If you haven't already, I would suggest installing the devel module to help you dig into the form structure.
As a FYI I ended up just using Formstack.com - which gives you the ability to easily map custom fields created in Highrise with the form you create using Formstack. Upon creating a form with Formstack I embedded the JavaScript tag provided and was good to go.

How do I escape ${} in my Tridion Component Template that is consumed by multiple templates?

I am running into a situation where I have a fied with the value ${test}, in my component template that renders this the value comes out ok the problem comes in when another template calls this component and templates using ##RenderComponentPresentation(Component.ID, MyFirstTemplate)## at this point the ${test} is evaluated and because there is no such item on the component or in the package it evaluates to nothing.
I have Component Template One that reads the value of a Component field (which contains: ${test})
This template renders fine, I get back "${test}"
Now I have Component Template Two that calls ##RenderComponentPresentation(Component.ID, ComponentTemplateOne.ID)##
This is where the ${test} now gets evaluated instead of retained so it goes from ${test} to "" because it doesn't find a variable or component field name with that name.
Component Template Two then gets called by Component Template Three in the same way ##RenderComponentPresentation(Component2.ID, ComponentTemplateTwo.ID)##
Since the ${test} has already been evaluated and lost in Component Template Two I no longer end up with ${test} I am still left with "".
I have tried:
##RenderComponentField('myField', 0, False, False)##
##RenderComponentField('myField', 0, True, False)##
##RenderComponentField('myField', 0, False, True)##
no luck.
The following was my work around and it seems to work:
Placing the "\" in front of both the open and close curly brace $\{test\}
I need to make sure I remove the "\" after the last Template (Page or Component) executes.
I have in place now a C# TBB that takes the "${test}" and does the following to it:
Converts the ${test} to $\{test\} in the initial template and a C# TBB on the Page Template that then returns it to the initial value of ${test}.
Is there a way to prevent this from happening or a way to avoid doing what i am doing to make this work?
Have you tried this link , you should be able to this with this link
##"$" + "{" + "test" + "}"##

Resources