Dynamic root node with Calendar Events Search Page asset


(Tom Stringer) #1

Matrix Version: 5.5.0.2

I’m having trouble getting the dynamic rootnode of a Calendar Events Search Page asset to update using keyword replacements to pass the desired rootnode value.

I have a Calendar Events Search Page (#54321) with its “Replacement Root node for the listing” set in the Dynamic parameters to get the variable parentID.

Then, in a paint layout, I’m trying to pass an ID (1234) to the parentID variable using the asset’s metadata.

It works if I hardcode the ID, but not if I try to do it dynamically.

So on the paint layout %asset_metadata_desiredValue% returns 1234.

Method 1:
Using the standard keyword repplacement value as a modifier technique:

%globals_asset_contents_raw:54321^with_get:parentID={asset_metadata_desiredValue}%

the %root_nodes% on the Calendar Events Search Page shows 1 (the primary root node).

Method 2:

Using the method outlined here

<script runat="server">
  print('%' + 'globals_asset_contents_raw:54321^with_get:parentID={' + %asset_metadata_desiredValue% + '}%');
</script>

the %root_nodes% on the Calendar Events Search Page also shows 1 (the primary root node).

(I’ve also tried using {globals_asset_metadata_desiredValue} to no avail).

Method 3:

But if I hardcode the variable, the %root_nodes% on the Calendar Events Search Page show 1234 and results are returned as expected:

%globals_asset_contents_raw:54321^with_get:parentID=1234%

Am I missing something? Or is it just borked?


(Chiranjivi Upreti) #2

%globals_asset_contents_raw:54321^with_get:parentID={asset_metadata_desiredValue}%

As point in the linked discussion, the global keyword evaluates at the top level where
the nested keyword {asset_metadata_desiredValue} would evaluate on the main frontend asset and not on the asset in the context in the default format.

Can you try using SSJS as below:

<script runat="server">
  print('%' + 'globals_asset_contents_raw:54321^with_get:parentID=' + %asset_metadata_desiredValue% + '%');
</script>

Here the asset level keyword would evaluate at asset level (i.e. when generating the default format’s content), while the global keyword will evaluate at top level after SSJS prints the correct global keyword with the already evaluated %asset_metadata_desiredValue% keyword. Something like:

%globals_asset_contents_raw:54321^with_get:parentID=1234%.

The example you have in your post using SSJS for “Method 2” has { } wrapped around %asset_metadata_desiredValue%, which is incorrect as it is not a nested keyword here. This would evaluated to something like this after SSJS processing, which you can see is not right:

%globals_asset_contents_raw:54321^with_get:parentID={1234}%.


(Tom Stringer) #3

Ah! Yes, the curly brackets were the culprit. Thank you!