Posts by j-pinder

    This isn't PHP related, but Perch related and having to do with updates. The present Dashboard isn't adapted for a strong Content-Security-Policy.

    As of right now, the CSP requires and unsafe-inline directive to permit inline styles and scripts. This defeats the whole purpose of the CSP.

    It's just a wishlist item. I would've loved to have carried on with Perch in other projects. Sad to see it go.

    So, apparently, this is due to an obscure white space issue in Perch's templating engine.

    Indents in the template code were reflected in the rendered HTML. I only needed to remove all indents in the template code and it rendered as it was supposed to.

    1. <!--* HTML Block — START *-->
    2. <perch:block type="html" label="HTML">
    3. <pre class="snippet language-html">
    4. <code>
    5. <perch:blog id="htmlBlock" type="textarea" markdown striptags editor="simplemde" size="xl" help="To render code, tab or indent four spaces.">
    6. </code>
    7. </pre>
    8. </perch:block>
    9. <!--* HTML Block — END *-->

    I found this out by using the Developer Console and looking at the actual source and not the Element Inspector. This also revealed a white space issue with blocks as well. Template comments(<!--* *-->) seem to alleviate this spacing issue to some degree, as found on the old forum.

    While I don't like that I cannot maintain indentation in the actual source code, I am happy that everything is now displayed as it should be.

    I'm using blocks to add chunks of example code to posts and pages.

    The default editors seem a little wonky to me when it comes to code blocks, else I would have just used them. To overcome the wonkiness, I thought to just make the <code> element a part of the block and use striptags to remove any default tags(<p>) from the output. I've not had a problem with striptags adding an indent before, but yeah. I also checked the CSS and JS to see if it might be there, even though it works fine in the template, but alas, I can see no reason why this should occur.

    Not exactly sure what, I'm missing here.

    Here's the code:

    This is the input in the editor:


    And here's the output:


    So, this was figured out.

    I hadn't realized that I had been adding regions to blog pages up to this point. I've been adding Regions so long, that I forgot when you didn't have one, it doesn't matter what other items are pulled in from the CMS, a region is still required for navigation.

    Problem solved. :S

    So, I'm rewriting URLS to make blog posts more friendly. The redirects work fine with one exception, I can type url/blog/anything-that-is-not-a-real-post and I don't get a 404 returned but instead an empty post. Top level pages(i.e. url/anything-that-is-not-a-real-page) all return the 404 error. Redirects to actual posts and archive, category, tag pages all work fine.

    Below is my .htaccess configuration. I'm not sure what may be affecting what in terms of the blog redirect, so hopefully someone can help.

    Here's my settings:


    This is the first time I have had this issue, but the perch_pages_breadcrumbs() function isn't working in sub-directories. I'm presently applying it to /blog/index.php and I set up a test/index.php to see if it was any sub-directory(it is) to no avail. Works fine on all pages in the root directory.

    1. <?php
    2. perch_pages_breadcrumbs(array(
    3. 'hide-extensions' => true,
    4. 'hide-default-doc' => false,
    5. 'template' => 'breadcrumbs.html',
    6. 'skip-template' => false
    7. ));
    8. ?>

    I'm using debug on the page, but the function isn't even being called, neither the template listed nor any links on my page. This is strange. How can it be right and wrong at the same time.


    Here is the code.

    This warning can be seen at Everything seemed fine until I uploaded to the live server.

    Warning: array_key_exists(): The first argument should be either a string or an integer in /home/cliftonheritage/public_html/cms/core/lib/PerchTemplate.class.php on line 1074

    The above error is what appeared above my perch_content_custom() listings:


    1. <?php
    2. perch_content_custom('Attraction Content',[
    3. 'count' => 5,
    4. 'sort-order' => 'RAND',
    5. 'page' => '/plan-your-visit/places-to-go/*',
    6. 'template' => '_places-to-go.html',
    7. 'each' => function($item) { $item['title'] = perch_page_attribute('pageTitle', ['_id' => $item['_pageID']], true); return $item; }
    8. ]) ?>

    This is what I get from debug. It's on my MAMP server, but nothing's printing out to the screen.

    1. Array
    2. ( [type] => 2 [message] => array_key_exists(): The first argument should be either a string or an integer [file] => /home/cliftonheritage/public_html/cms/core/lib/PerchTemplate.class.php [line] => 1074
    3. )