2
votes

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.

2
Try: <!-- TemplateBeginIf cond="ComponentTemplate.Metadata.section_name == key" --> - Andrey Marchuk
How did you check the variable value to as 0? Try @@key@@ before condition and see what you get and then compare with a package variable in template builder. - vikas kumar
I had tried this as well:<!-- TemplateBeginIf cond="ComponentTemplate.Metadata.section_name == key" --> It does not seem to work. - Vinda Sawant
Hi Vikas, I checked it the same way using @@key@@ and then I found out it is giving value as 0 . But in template builder in the package it shows me correct value as "test". - Vinda Sawant

2 Answers

6
votes

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.

2
votes

Please check following.

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

Package Image