Posts by Byron Fitzgerald

    A shared region sounds like what you are looking for. You can declare the region anywhere - like a perch layout in your case .

    Code
    1. perch_content_create('Contact Details', [
    2.     'template' => 'shared/contact',
    3.     'shared' => true
    4. ]);


    Combining this with perch_content_custom you can share the data anywhere on your site, whilst letting you use different templates.

    Code
    1. perch_content_custom('Contact Details', [
    2.     'template' => 'shared/footer',
    3. ]);

    Just wanted to make sure I was giving you the right information, hopefully the below helps


    Each website page will use a page template. These should be found in the pages folder in templates. For you I guess this would be path/to/webiste/cms/templates/pages. In these pages you should see parts which look similar to

    Code
    1. perch_content_create('Article',[
    2. 'template' => 'general/article.html'
    3. ])

    The 'Article' string here represents the region name - which shows up in the CMS admin area. If you don't see this, go into your region you want to add the formatting options to, and click the region options tab. There should be a select option for template. This is what you'll need to look for in the next step


    These templates should be located in path/to/webiste/cms/templates/content. In these templates will be your HTML markup. Perch uses an XML template system to define inputs, so you'll be looking for a tag that looks similar to the following

    Code
    1. <perch:content id="content" type="textarea" label="Content" />

    You should be able to search the labels to find the correct field. You'll need to update this tag to the follow (Keeping your ID and label the same as you currently have)

    Code
    1. <perch:content id="content" type="textarea" html="true" editor="redactor" label="Content" />

    Could you not add a manual redirection in your page file?


    Code
    1. if($campaignSlug = PerchUtil::post('lm_campaign_name_slug')) {
    2.     PerchSystem::redirect($campaignSlug.'/downloads')
    3. }

    and then have lm_campaign_name_slug as as hidden field

    What are the textarea inputs looking like in your template? If your looking to use the WYSIWYG editor it should look similar to below.

    Code
    1. <perch:content id="body" type="textarea" label="Article body" html editor="redactor">

    If that looks good are you getting any JS errors in your console?

    The perch:before and perch:after tags are executed only once, Before the collections are displayed, and after the collections are displayed. As your perch:before tags are executed on the second iteration- as the first is seperated - perch won't recognise the tag. You'll need to move your perch:before tags into the first if block for them to be executed. However as the first if block is always the first item, the perch:before tags are redundant. To keep things consistent you can remove the perch:before and perch:after tags and stick with perch:if


    Code
    1. <perch:if exists="perch_item_first">
    2. <perch:content id="post_title">
    3.     <ul>
    4. <perch:else>
    5. <li><perch:content id="post_title"></li>
    6. </perch:if>
    7. <perch:if exists="perch_item_last">
    8.     </ul>
    9. </perch:if>

    Sort of grasping at straws now, but if you got to the PerchShop_Orders.class.php file and look for the create_from_cart function.


    If you could add the following

    Code
    1. PerchUtil::debug(PerchUtil::json_safe_encode($cart_data));
    2. $data = [
    3. 'orderStatus' => 'created',
    4. //... rest of data
    5. 'orderShippingAddress' => $ShippingAddress->id(),
    6. ];
    7. PerchUtil::debug(PerchUtil::json_safe_encode($data));

    This will hopefully output something into the debug that might hint to where things are going wrong

    From looking at the Perch Shop order code the two offending fields seem to be

    Code
    1. 'orderItemsTotal' => $cart_data['total_items'] + $cart_data['total_items_tax'],
    2. 'orderSubtotal' => $cart_data['total_items_with_shipping'] - $cart_data['total_discounts'],

    So it looks like it could be a type coercion error. Can you check your cart for the fields above?

    You'll have to loop through each block individually as well. Can't remember the exact syntax, but you can always do a var_dump() to get the exact structure of the array returned

    Code
    1. perch_content_custom('Videos', [
    2. 'each' => function($item) {
    3.                 foreach($item['_blocks] as &$block) {
    4.     if($block['youtube_video']['description']) {
    5.     $block['youtube_has_description'] = true;
    6.     }
    7.     }
    8.               }
    9. ])

    The <perch:if> tag doesn't work with the output attribute. Your best bet would be to use the each option in perch_content_custom and add a key if the description exists


    Code
    1. perch_content_custom('Videos', [
    2.     'each' => function($item) {
    3.                 if($item['youtube_video']['description']) {
    4.                     $item['youtube_has_description'] = true;
    5.                 }
    6.               }
    7. ])

    Then in the template you can use

    Code
    1. <perch:if exists="youtube_has_description">
    2. <perch:content id="youtube_video" type="youtube" output="description"/>
    3. <perch:else>
    4. Output something else
    5. </perch:if>

    You'll likely need to tweak the above so it works correctly, haven't used the youtube field type before.