With_get / with_post keyword modifiers don't populate %globals_get% / %globals_post%


(*) #1

I’m testing out the ^with_get or ^with_post keyword premodifiers and finding that the %globals_*% keywords (docs) aren’t being populated – or might being populated too late.

I’m following the example in the documentation and I have two Standard Page assets that look like so; the first includes the contents of the second, with the addition of the GET parameter.

Page Asset 1

%globals_asset_contents:12345^with_get:root=187%

Page Asset 2 (ID 12345)

globals_get: %globals_get%
globals_get_root: %globals_get_root%
nested_get_root: %nested_get_root%

The result of hitting the URL for Page Asset 1 is HTML that looks like this:

globals_get: []
globals_get_root:
nested_get_root: 187

The same behaviour is seen for POST as well. After seeing that the %globals_get keywords didn’t have the parameter I was passing, I tried using the %nested_get_*% keyword that’s supposed to be for Nested Content assets and tada, it worked. This makes it feel like the processing order is amiss; either globals being populated too late or these keywords being replaced too early.

I’m on Matrix Version: 5.3.3.0, which means these premodifiers are available and I’m using them successfully in other contexts (eg Standard Page to Asset Listing’s default type Bodycopy) where %globals_get% is populated.

What do you think, looks like a bug?


Accessing the `Content Container Template` & `Content Container` via keywords
(Chiranjivi Upreti) #2

Hi David,

That is an expected behaviour. Using %globals_asset_contents:XXX% keyword behaves in similar way as nesting the given asset in the nested content container. %nest_*% is correct way to access the get/post vars passed to nested asset (nested via %globals_asset_content% keyword or nested content type).

%globals_*% keyword is evaluated at the global context level where the get vars passed to the nested asset (nested via %globals_asset_content% keyword using pre-modifier “with_get”) will not be available.

Chiran


(*) #3

Thanks for the clarification.

In that case, could you please document the availability of the %nested_*% keywords for use in this manner? I’m not actually using the Nest Content Content Type, but its documentation page is the only location where I could find these keywords (see https://matrix.squiz.net/search?query=nested_get) – hence my surprise when they actually did work.

Also, it would helpful for users if you were to document (perhaps in this area too) that the usage of ^with_get and ^with_post, or in Nest Content Content Types won’t modify/be reflected in the %globals_*% keywords, and that they’ll only ever refer to the original HTTP request. The current wording refers to accessing variables in the "current page request" so you can understand how that becomes ambiguous when the current page and the request are being modified.

Thanks.