Changing master page and regions

  • Hi


    In Runway if I change a page to have a different master, should it assign the regions that the master is set to? Or have I done something wrong as the new regions are coming in as new.


    Should I delete the page and re-add it with the desired master to avoid this?


    Kind Regards

    Wayne

  • Ah, that could be a way around it. Currently, I'm using the method of;


    <?php perch_content('CatTitle'); ?>


    Then setting the regions to copy from another master.


    Instead, if I change the regions on the new master to this method;


    Code
    1. perch_content_custom('myRegion', array(
    2. 'template' => 'my_template.html',
    3. ));

    that should enable me to achieve the results I'm after?

  • The template you specify in perch_content_custom() is used to render the template at run time. The template your specify in perch_content_create() is used in the edit form in the control panel.


    Create the region "My Region" if it doesn't already exist:

    PHP
    1. perch_content_create('My Region', [
    2. 'template' => 'some_template.html'
    3. ]);


    Output the cached rendered template for the region "My Region":

    PHP
    1. perch_content('My Region');


    If you only use perch_content() without creating the region first, Perch is smart enough to create it for you instead of penalising you for not explicitly creating the region first. In this case you would need to edit the region settings (including choosing the region template) via the control panel.



    that should enable me to achieve the results I'm after?

    I'm not 100% sure I understand what you are after. If you want to specify the edit form template for new regions, use perch_content_create() to create the region as demonstrated above.

  • Coming back to this. The client is adding content (which I can see in the admin), but its not showing on the page.


    To re-cap, I'm using these calls for the content;


    PHP
    1. <?php
    2. perch_content_create('CatTitle', array(
    3. 'template' => 'text.html'
    4. ));
    5. ?><img src="https://community.perchcms.com/attachment/188-screenshot-2020-04-16-at-15-47-44-png/?thumbnail=1" class="woltlabAttachment" data-attachment-id="188" id="wcfImgAttachment0">

    And there is content in the region (see attachment).


    But can't work out why the content isn't showing on the page?

  • Thanks Hussein


    Changing the tags to perch_content_custom() now outputs the content, but if I go back to my original issue of changing the master, it doesn't create the regions.


    Is there a way to create the regions and output the content. Or do I need to get my client to change masters while the tags are perch_content_create() then change them to perch_content_custom() when they want to add content?

  • In a master template you would normally include both if you want to add default settings to the region (e.g. template, is it a shared region, is it a multiple-item region, etc). This way the editor does not have to manually configure the region themselves every time they create a new page.



    PHP
    1. perch_content_create('Blocks', ['template' => 'blocks.html']);
    2. perch_content('Blocks');


    A multiple item-region:




    And you can stick all your perch_content_create()s at the top of the page if you prefer: