Forum

Thread tagged as: Problem

custom content repeated twice using blocks

I'm using Blocks and custom content to retrieve data from a particular page and blocked region. As per your help on this question: https://forum.grabaperch.com/forum/10-08-2015-custom-content-using-blocks

The custom content is now being retrieved/displayed on another page using a specified template. When it renders the output on the page it does so twice?

I've tried count = 1

This didn't happen on my local MAMP setup but did on the live server. Thomas on my previous thread above has experienced the same thing if you see his comments.

Local server setup:

Perch: 2.8.14, PHP: 5.5.3, MySQL: 5.5.33, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.14), assets (2.8.14), categories (2.8.14), perch_forms (1.8.3)

Live Server setup:

Perch: 2.8.14, PHP: 5.3.3, MySQL: 5.1.73, with PDO
Server OS: Linux, cgi-fcgi
Installed apps: content (2.8.14), assets (2.8.14), categories (2.8.14), perch_forms (1.8.3)
Mark Watts

Mark Watts 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you show me the code you're using?

Product page where the brand logos are added:

<!--* Main heading and introduction and graphic *-->
<perch:before>
<perch:template path="content/blocks/introduction_block.html" />

<!--* Keypoints *-->
<div class="keypoints keypoints--para">
    <h2><perch:content id="keypoints-heading" type="text" label="Heading" required="false" title="true" /></h2>
    <p class="keypoints__intro"><perch:content id="keypoints-intro" type="textarea" label="Introduction Text" html="false" size="s" /></p>

    <ul>
    <perch:repeater id="keypoints" label="Keypoint items">
        <li>
            <div class="keypoints__image">
                <img src="<perch:content id="keypoint-image" type="image" width="215" label="Image" />" alt="<perch:content type="text" id="alt" label="Description" required="false" help="Image name" />" srcset="<perch:content id="keypoint-image" type="image" width="215" label="Image" density="2" /> 2x, <perch:content id="keypoint-image" type="image" width="215" label="Image" density="3" /> 3x">
            </div>
            <h3 class="keypoints__title"><perch:content id="keypoint-title" type="text" label="Keypoint title" /></h3>
            <p class="keypoints__text"><perch:content id="keypoint-text" type="textarea" label="Keypoint text" size="xs" /></p>
        </li>
    </perch:repeater>
    </ul>
</div>

</perch:before>


<perch:blocks>
<!--* Brand logos *-->
<perch:template path="content/blocks/brand_logos_block.html" />

<!--* Text *-->
<perch:template path="content/blocks/text_block.html" />

<!--* Lists used for things like Features or Benefits *-->
<perch:template path="content/blocks/list_block.html" />
</perch:blocks>

Brand logos block template: (content/blocks/brand_logos_block.html)

    <perch:block type="brand-logos" label="Brand logos">
<ul class="brand-logos">
    <perch:repeater id="brand-logos" label="Add a brand logo">
    <li><img src="<perch:content id="brand-logo" type="image" width="125" label="Image" bucket="brands" />" alt="<perch:content type="text" id="alt" label="Description" required="false" help="Brand name" />" srcset="<perch:content id="brand-logo" type="image" width="125" label="Image" density="2" bucket="brands" /> 2x, <perch:content id="brand-logo" type="image" width="125" label="Image" density="3" bucket="brands" /> 3x"></li>
    </perch:repeater>
</ul>
    </perch:block>

Homepage with custom content wanting to load brand logos from products page:

    perch_content_custom('Product Details', array(
        'page' => '/products/*',
        'template'  => 'blocks/brand_logos_blocks.html',
    ));

Homepage custom content template (blocks/brand_logos_blocks.html) which has the required perch:blocks tag pair:

<perch:blocks>
<h3 class="home-title-impact">Big brands and many more.</h3>
    <perch:block type="brand-logos" label="Brand logos">
<ul class="brand-logos">
    <perch:repeater id="brand-logos" label="Add a brand logo">
    <li><img src="<perch:content id="brand-logo" type="image" width="125" label="Image" bucket="brands" />" alt="<perch:content type="text" id="alt" label="Description" required="false" help="Brand name" />" srcset="<perch:content id="brand-logo" type="image" width="125" label="Image" density="2" bucket="brands" /> 2x, <perch:content id="brand-logo" type="image" width="125" label="Image" density="3" bucket="brands" /> 3x"></li>
    </perch:repeater>
</ul>
    </perch:block>
</perch:blocks>

This all displays correctly, meaning a list of brand logos when on my local MAMP setup. But on the live server it loads the set of brand logos twice:

Simplified version of the Local mamp website output:

<h3 class="home-title-impact">Big brands and many more.</h3>
<ul class="brand-logos">
    <li><img src="/admin/resources/brands/beko-w125.png" alt="" srcset="/admin/resources/brands/beko-w125@2x.png 2x, /admin/resources/brands/beko-w125@3x.png 3x"></li>
etc etc etc
</ul>

Simplified version of the Live website output:

<h3 class="home-title-impact">Big brands and many more.</h3>
<ul class="brand-logos">
    <li><img src="/admin/resources/brands/beko-w125.png" alt="" srcset="/admin/resources/brands/beko-w125@2x.png 2x, /admin/resources/brands/beko-w125@3x.png 3x"></li>
etc etc etc
</ul>
<h3 class="home-title-impact">Big brands and many more.</h3>
<ul class="brand-logos">
    <li><img src="/admin/resources/brands/beko-w125.png" alt="" srcset="/admin/resources/brands/beko-w125@2x.png 2x, /admin/resources/brands/beko-w125@3x.png 3x"></li>
etc etc etc
</ul>

Note the live version repeats the block twice?

Any ideas?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you confirm it's still happening in the current version?

Upgraded to 2.8.15 and resaved the regions and still the same. Thomas experienced the same problem, see his comments here:

https://forum.grabaperch.com/forum/10-08-2015-custom-content-using-blocks

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, thanks, we'll have another attempt at reproducing it.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like you have multiple <perch:blocks> section in your template, along with content in the <perch:before> section.

I can't get the behaviour to occur with a valid template.