2

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.

Ram G
  • 4,829
  • 1
  • 16
  • 26

2 Answers2

6

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.

Paul Russell
  • 281
  • 2
  • 6
2

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

Puntero
  • 2,310
  • 15
  • 18
vikas kumar
  • 2,444
  • 15
  • 25
  • Hi Vikas, 1. There is only 1 variable with the name "Key". 2. I also verified the location in package. It seems to be correct. – Vinda Sawant Oct 10 '12 at 09:13
  • This is bit strange, did you verify it after your c# tbb execution, because package result may change after each tbb execution...otherwise try using any other variable name... – vikas kumar Oct 10 '12 at 09:18