Question

Photo of Ben Goshow

0

Is it possible to use the current Page ID within a Content Channel filter?

Screen Shot 2017-01-04 at 3.13.28 PM.png

Is it possible to use a Page Parameter in a Content Channel filter? What's the syntax for that?

In the screenshot, I've defined a Content Channel Item with an Image Attribute. I want to display that Image on the Page whose ID matches the ID I set in the Content Channel. And I'd like to be able to use this block for every page using this Layout, so the filter variable would need to be dynamic. The above is my best guess, but it doesn't work. Is it possible with a different syntax, or is this outside the intention of the Content Channel View Block?

  • Photo of Ben Goshow

    0

    With the help of @arranf and @jonedmiston, I found this solution to assign Page header images using Content Channel Items and Lava Entities.

    1) I created a Content Channel called "Page Headers".

    2) I created a Content Channel Item Attribute "HeaderImage" and an Item Attribute "PageID" (Integer Field Type).

    Screen Shot 2017-01-05 at 9.29.30 AM.png

    3) I created a Content Channel Item and set the Page ID and header image.

    4) I assigned the following Lava to an HTML Block on the Page whose ID I entered into the Content Channel Item, and was able to then use "headerImgGuid" to display the image on the page. (Note: the Content Channel ID is 2026)

    {% contentchannelitem where:'ContentChannelId == 2026 && PageID == {{CurrentPage.Id}}' %}
    {% for item in contentchannelitemItems %}
    {% capture headerImgGuid %}{{ item | Attribute:'HeaderImage','RawValue' }}{% endcapture %}
    {% endfor %}
    {% endcontentchannelitem %}

  • Photo of Ben Goshow

    0

    This is much easier now with Page Attributes (v6.3+)! You can define them in the Site Settings, then reference them in an HTML Block on the Page using something like this:

    {{ CurrentPage | Attribute:'BackgroundImage' }}