0

I've created a view block that has a contextual filter with a Content ID from URL. The view is only to appear on my content types if the field_aside_content has any data in it.
This field is just a paragraph reference type to a selected number of custom paragraphs that are to appear in the aside region of my page.

My problem is if I only select a media paragraph type in this content, the block doesn't display on the page. If I then select a paragraph type that is text-based, then the block displays both the media and text content. If I remove the image, the text shows fine on its own.

What I've noticed is that the only time this block doesn't seem to show up on the page is when I select a media-type of paragraph.
My image, video, map and slider paragraph types won't show up on their own unless they're accompanied by some sort of text-based paragraph type or if a menu or some other block is already in the aside that this block shows up in.

It's weird too because if I check the preview of the page when I'm editing the view, it shows the media content showing up, it just doesn't seem to actually show on the published page.

Does anyone have any idea as to what is happening here?

I've also attached a screenshot of my view settings below to show what I've done in case something needs to be tweaked here: View settings

EDIT:

My page.html.twig file has the following code for the aside:

{% set has_aside = page.sidebar|render|striptags|trim %}
  {% if has_aside %}
  {% block sidebar %}
    <div{{ aside_attributes.addClass(aside_classes).setAttribute('id', aside_id) }}>
      {{ page.sidebar }}
    </div>
  {% endblock %}
  {% endif %}

I've noticed that if I remove the |trim filter, then the images will show up but the issue that then occurs is that even if my aside doesn't have any content in it, it will still show up on a page that doesn't need it.

1 Answer 1

0

The |trim twig filter in my page.html.twig was my problem as to why those blocks weren't appearing. Also, the reason that my aside always shows when that filter is removed was that in dev, it has twig debug on spitting code in that section. When twig debug is off on my production server, the aside won't appear unless content is in it and all my blocks now appear as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.