• Resolved shaunbowen

    (@shaunbowen)


    I have recently been adding some custom layouts to my theme, using the ‘Theme Defined Layouts’ section to list them with thumbnails.

    This is working great, however I can’t for the life of me figure out what defines the list order! It’s not alphabetical, as there as the order goes like this currently:

    Scrolling Gallery
    Collapsing Columns 4 > 2 > 1
    Mixed Transparent Rows
    Collapsing Columns 6 > 3 > 2
    Background Image Faded

    These are my own titles set in the JSON files.

    It is also not in date order, as ‘Mixed Transparent Rows’ is the latest to be added and has been put in the middle of the list.

    Is there another attribute I can add to my JSON file along with “name” and “description” to help organise them better?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor alexgso

    (@alexgso)

    Hi shaun,

    Layouts aren’t ordered by default, and they’re as they’re identified by WordPress. Unfortunately, It’s not possible to order them via an attribute, but you can order them with PHP. The siteorigin_panels_prebuilt_layouts will allow you to sort the prebuilt layouts using your desired ordering. You’ll want to do this using usort and you can see an example of how to filter an array based on values here.

    Kind regards,
    Alex

    Thread Starter shaunbowen

    (@shaunbowen)

    Hi Alex,

    Many thanks for the help. I will need to investigate the use of this as it’s a bit advanced for my limited PHP skills!

    Kind regards,

    Shaun

    Plugin Support Andrew Misplon

    (@misplon)

    Hi Shaun

    Alex has added a new section to the Developer Docs for sorting. I hope it helps:

    https://siteorigin.com/docs/page-builder/bundling-prebuilt/#heading-sorting

    Cheers,

    Andrew

    Thread Starter shaunbowen

    (@shaunbowen)

    Many thanks for that, my talented programmer colleague Rob has already managed to write the following snippet for functions.php which allows a new value to be added to the JSON page layout files:

    // sorts the prebuilt layout files by sort attribute
    add_filter( 'siteorigin_panels_prebuilt_layouts', 'dh_so_layout_filter' );
    function dh_so_layout_filter($data){
        usort($data,'dh_so_layout_filter_compare');
        return $data;
    }
    function dh_so_layout_filter_compare($a, $b) {
        return $a["sort"] - $b["sort"];
    }

    Simply add a value of ‘sort’ under the Title and Description values:

    "name": "Scrolling Gallery",
    "description": "A scrolling gallery of images, icons, logos or content.",
    "sort": 9

    …and this will define the order of the layouts.

    Plugin Contributor alexgso

    (@alexgso)

    Hi Shaun,

    It’s great to hear they were able to come up with a method that allowed you to use a custom sort order. ??

    Please feel free to post another thread if anything else comes up.

    Kind regards,
    Alex

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Change display order of ‘PreBuilt Layouts’’ is closed to new replies.