Our Blog > Blog Detail

Web Content Viewer- Asponte Custom Skin

Actions

InContext Primer Part 2: Further Examination of InContext

  • Created By: Kapish Aggarwal
  • Updated: February 23, 2016

In the previous part of this blog series, I talked about the InContext tag and how it works. This part we will further explore the tag along with potential pitfalls.

 

The first point to be made is that InContext is technically a plugin, not an Element or Property tag. With InContext tags, we can utilize Property or Element tags within the InContext declaration. Unlike with Property or Element tags, this means that using the context "selected" does not mean having to hard code the WCM ID of a piece of content. This means the following code:

Is functionally identical to:

 

In addition, we also need to understand the scope of how the context changes. Using the example content from the previous part, let's add another section of code to the Menu component.

Again, using the "Sample Article" content that comes with WCM as the preview context, I get the following for one of the result outputs:

Outside InContext Tag Result 1

Title Current: Sample Article

Title Autofill: 1700 Building

Inside Autofill InContext Tag Result

Title Current: 1700 Building

Title Autofill: 1700 Building

Inside PortletContext InContext Tag Result

Title Current: Sample Article

Title Autofill: Sample Article

 

Note how when the context is changed to "portletContext", the "autofill" query refers to the Sample Article and not one of the buildings. This is because InContext doesn't just alter the "current" context reference. Even though we are inside a Menu result design, InContext sets the context as if the presentation code were executing as a standard Presentation Template against the new context. This means that within the InContext tag, there is no concept of the Menu that contains the code. Hence "autofill" maps back to the "current" context. To further illustrate this, notice how the Placeholder tag is used in the code above.

 is used outside the InContext tag but not inside. That is because the "listnum" tag has no meaning outside of a listing component (e.g. Menu, Navigator, etc.). If we were to place this tag within the InContext tag, it would lose it's reference since it no longer sees the listing component. 

Try executing the above tweak, you'll get the following behavior:

Outside InContext Tag Result 1

Title Current: Sample Article

Title Autofill: 1700 Building

Inside PortletContext InContext Tag Result

Title Current: Sample Article

Title Autofill: Sample Article

 

The section that uses the InContext tag to change to "autofill" is missing altogether. This because the entire context fails to execute since the "listnum" tag has no meaning within the InContext block. It causes a failure for the whole context execution and none of the HTML renders. You'll notice similar behavior if you try to use "listnum" in the Header or Footer section of the Menu component. The whole Menu component will fail to render.

 

InContext can be a powerful tool, but it does need to be used with caution.

 

Contact Form- Asponte Custom Skin

Actions

Contact Us

*
*


Submit
Call Us 888-926-9434
Complementary Content
${loading}