Jump to content

Custom Block - Bringing "New Images" from Gallery


AlexWright

Recommended Posts

Posted

Hi all, bit of a weird situation here. I have a Custom Block based on the "Images Feed" from gallery. The code for this is:

{expression="\IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_browse.js', 'gallery'))"}
{{if !empty( $images )}}
<div class='ipsBox'>
    <h2 class='ipsType_sectionTitle ipsType_reset'>{lang="new_images"}</h2>
    <div data-ipsPhotoLayout data-ipsPhotoLayout-itemTemplate='gallery.patchwork.indexItem' data-ipsPhotoLayout-maxRows='3' class='ipsPad ipsClearfix cGalleryPatchwork_index'>
        <ul class='ipsList_inline'>
            {{foreach $images as $image}}
                <li data-role='patchworkImage' data-json='{$image->json()|raw}'>
                    <a href='{$image->url()}'><img src='{file="$image->small_file_name" extension="gallery_Images"}' alt='' class='ipsJS_hide'></a>
                </li>
            {{endforeach}}
        </ul>
    </div>
</div>
{{endif}}

It works when it gets set into the home page. It works when you refresh the home page.

Then you navigate to any other part of the site, and back to the homepage, and it breaks. It's as if it's not caching right, or something. It goes entirely blank. Can anyone help with this? I'm still getting my head around php and template logic.

Here's what it's doing:

First load:

image.thumb.png.65ea1ca80338b8ba3dc7e9a39bb9452d.png

Reload:

image.thumb.png.34aa1f06f52745edbcb06b63d26e7b66.png

Cheers!

Posted

Update and some random strangeness with this:

The preview in the ACP can be refreshed again and again without incident and without the images depopulating. This block also shows on /?_fromLogout page and works -without flaw- there. It does not work on the /?_fromLogin. It also doesn't work on the Home page, or any other Pages page more than Once. Any refresh of those pages causes it to depopulate for approximately 60 seconds, at which point it appears to populate, and upon refresh again depopulates. This sounds like a caching issue for this block?

Another update. Including this outside of a "Pagebuilder" page seems to work, with the {block=""} logic. Just going to have to rebuild my home page using this.

Posted

Check for javascript errors, and check the HTML source to make sure you actually have images being output. The photolayout javascript UI widget can break if invalid JSON is output for an image, so you may have a bad image getting included in the feed periodically causing this issue.

Posted
On 1/21/2019 at 10:55 AM, bfarber said:

Check for javascript errors, and check the HTML source to make sure you actually have images being output. The photolayout javascript UI widget can break if invalid JSON is output for an image, so you may have a bad image getting included in the feed periodically causing this issue.

It's odd. It works perfectly fine from a Manual page by including the block. Just not on a page builder. 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...