We are transitioning over to a new forum platform. Please post new issues there. Existing threads will be dealt with here unless you choose to move them over. Visit the new forum


Thread tagged as: Problem, Error

Perch Blocks when first added appear in the wrong order

I noticed that when I add a lot of Blocks, after hitting save the order can be messed up.

Here's my diagnostic report:

Perch: 2.8.3, PHP: 5.5.17, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $, with PDO
Server OS: WINNT, cgi-fcgi
Installed apps: content (2.8.3), assets (2.8.3), categories (2.8.3), perch_events (1.9.2), perch_forms (1.8.2)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_events', 'perch_forms', );
PERCH_PATH: D:\Domains\***domain***.co.uk\wwwroot\2015\perch
PERCH_CORE: D:\Domains\***domain***.co.uk\wwwroot\2015\perch\core
PERCH_RESFILEPATH: D:\Domains\***domain***.co.uk\wwwroot\2015\perch\resources
Image manipulation: GD
PHP limits: Max upload 128M, Max POST 128M, Memory: 128M, Total max file upload: 128M
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: D:\Domains\***domain***.co.uk\wwwroot\2015
HTTP_HOST: 2015.***domain***.co.uk

Here's my template:

    <perch:block type="full_width_text" label="Full Width Text">
        <div class="block full_width_text">
        <perch:content id="text" type="textarea" label="Text" markdown="true" editor="markitup" />
    <perch:block type="text_images" label="Text and small images">
    <div class="block text_and_small_images">
        <perch:repeater id="images" label="Images" order="2">
            <img src="<perch:content type="image" id="image" label="Image" width="230" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="e.g. View of Hethpool House"  />" class="photoright" />
        <perch:content id="text" type="textarea" label="Text" markdown="true" editor="markitup" order="1" />
    <perch:block type="text_big_image" label="Text and larger image">
    <div class="block text_big_image">
          <div id="rightColumn" style="float:right; width:490px;">
            <img src="<perch:content type="image" id="image" label="Image" width="490" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="e.g. View of Hethpool House"  />" style=" border-style:solid;border-width:4px; border-color:#FFFFFF;" />
            <perch:if exists="photo_credit"><p style="float:right;font-size:11px;"><i><perch:content id="photo_credit" type="text" label="Photo Credit"  /></i></p></perch:if>
          <perch:content id="text" type="textarea" label="Text" markdown="true" editor="markitup" order="1" />
    <perch:block type="full_image" label="Full width image">
        <div class="block full_image">
        <img src="<perch:content type="image" id="image" label="Image" width="900" />" alt="<perch:content type="text" id="alt" label="Description" required="true" help="e.g. View of Hethpool House"  />" />
    <perch:block type="three_up" label="Three feature boxes">
        <div id="box3" class="box3_2014"> 
            <perch:repeater id="feature_boxes" label="Images" max="3">
                <div class="box3singel  <perch:every count="3">last</perch:every>">
                        <a href="<perch:content id="link" type="text" label="Link" order="2"  />"><perch:content id="box_heading" type="text" label="Box heading" order="1"  /></a>
                    <br />
                    <perch:if exists="image"><a href="<perch:content id="link" />"><img src="<perch:content type="image" id="image" label="Image" width="264" height="175" order="3"  />"  alt="<perch:content type="text" id="alt" label="Description" help="e.g. View of Hethpool House" order="4"  />" /></a></perch:if>
                        <perch:content id="box_text" type="text" label="Text"  help="Appears below the image." order="5" /> <a href="<perch:content id="link" />"><perch:content id="link_text" type="text" label="Link text" help="e.g. Read more here." order="6" /></a>

            <div class="clearfix" style="clear:both;"></div>
    <perch:block type="menu" label="Menu">
        <div class="menu">
        <h3><perch:content id="menu_heading" type="text" label="Menu heading" /></h3>
            <perch:repeater id="menu_items" label="Menu Items">
                <li><perch:content id="menu_item" type="text" label="Menu item" /></li>
    <perch:block type="code_block" label="Code block">
        <perch:content id="text" type="textarea" label="Code" markdown="false" html="true" editor="markitup" help="Paste in JS code." />

I added six content blocks, and in each one, I put a number, written out in words.

They were as follows:

  • One - Full Width text
  • Two - Full Width text
  • Three - Full Width text
  • Four - Text and small images
  • Five - Code
  • Six - Full Width text

When I hit save the Blocks were in the following order:

  • Five
  • Four
  • One
  • Six
  • Three
  • Two

I then deleted all the blocks, hit save and then re-added them again as before. This time, only four blocks were saved. I deleted again and re-added as before, and this time just two blocks were saved. Then I deleted them all again and re-added a third time and this time all blocks were saved in the same (wrong) order as before. I tried again, making them all the same type of block, and still ended up with the wrong order.

A friend of mine mentioned he'd sometimes also experienced Blocks being added in the wrong order, so I thought I would report it. Can see that this is going to be great for clients though.

Paul Bell

Paul Bell 0 points

  • 4 years ago

I noticed a problem too when adding blocks it didn’t save them in the right order (4 blocks, 2 text and 2 images as in the example).

I dragged them into the right order which worked alright although it did confuse me at first when I looked at the page to check it.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Can you confirm that this only happens if you fail to save the item before adding the blocks?

I found that this happens if I have a new region, and add 6 blocks without saving in between. When I'd deleted all the blocks, saved and added another six, I still had problems of mis-ordered blocks, and sometimes missing blocks, which is the more worrying situation. When I save in between adding each block, the results were a lot more reliable.

In testing just now I found that as long as I save after adding the first block, the subsequent blocks are all added in the right order. Hope that helps.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Here's what I'm seeing:

  1. Create new item
  2. Fill in a non-block field
  3. Save
  4. Add blocks
  5. Save

Order is maintained. But if I do this:

  1. Create new item
  2. Fill in fields
  3. Add blocks
  4. Save

The order sometimes gets jumbled, which is absolutely a bug.

Yes, I think that's what I'm seeing too, though my template only contains blocks, so I can't comment on the effect of filling in a non-block field, but I also find that order is maintained if I save after adding the first block - all subsequently added blocks then seem to behave themselves. It's something that can easily be worked around by re-ordering afterwards, but felt like a bug to me.

The other issue that could be related is if

  1. I add six blocks,
  2. SAVE,
  3. delete them all,
  4. DON'T click save
  5. Add six more blocks,
  6. Save

None of the blocks are there.

Or if I

  1. I add two blocks,
  2. SAVE,
  3. delete them all,
  4. DON'T click save
  5. Add THREE more blocks,
  6. Save

Only the third one is there (the first two aren't saved).

It's almost as though the blocks that are added have the same ID as the blocks that have been deleted, and so aren't saved in the system. I guess this is a separate but related issue. Hope this is helpful.

Yes, I was about to create a thread about this.

Basically once one bit of the block is saved, it maintains order. Otherwise, I consistently get the reordering/grouping behaviour when saving the block (with more than one item) for the first time.

Drew McLellan

Drew McLellan 2638 points
Perch Support

The first time issue is now fixed, so I don't need any more information on that.

Working on the "deleting lots of items then recreating them again" scenario now.

Drew McLellan

Drew McLellan 2638 points
Perch Support

And I think we've got the deletion problem, too.

Brilliant! Thanks.

Drew did you fix the deleting and recreating issue? Looks like this issue might be what I am suffering. I have been trying to build 5 blocks - only 3 ever show even when I add more - up to 8 blocks - order does change as well. tried deleting them all and adding 1 by 1 but still get the 3.