简体   繁体   中英

Issue in accessing package variable in Dreamweaver Template

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. Eg :

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.

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

包装图像

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM