Posts by j-pinder
-
-
Perch is great. It's really a shame that this seems the end.
-
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.Code- <!--* HTML Block — START *-->
- <perch:block type="html" label="HTML">
- <pre class="snippet language-html">
- <code>
- <perch:blog id="htmlBlock" type="textarea" markdown striptags editor="simplemde" size="xl" help="To render code, tab or indent four spaces.">
- </code>
- </pre>
- </perch:block>
- <!--* 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:Code- <perch:block type="html" label="HTML">
- <pre class="snippet language-html">
- <code>
- <perch:blog id="htmlBlock" type="textarea" markdown editor="markitup" striptags size="xl" help="To render code, tab or indent four spaces.">
- </code>
- </pre>
- </perch:block>
- <perch:block type="cssCode" label="CSS">
- <pre class="snippet language-css">
- <perch:blog id="cssCodeBlock" type="textarea" markdown editor="simplemde" striptags size="xl" help="To render code, tab or indent four spaces.">
- </pre>
- </perch:block>
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. -
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.Code- Options -Indexes +Includes
- ErrorDocument 404 /404.php
- ErrorDocument 403 /404.php
- #Charset
- AddDefaultCharset utf-8
- AddCharset utf-8 .htm .html .js .css
- <IfModule mod_rewrite.c>
- RewriteEngine on
- # 301 redirect other links in our page
- RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^\ ]+)\.php
- RewriteRule ^/?(.*)\.php$ /$1 [L,R=301]
- # Redirect index files with or without extensions to root.
- RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index(\.(html?|php))?\ HTTP/ [NC]
- RewriteRule ^((?:[^/]+/)*)index(\.(html?|php))?$ /$1 [R=301,L,NC,NE]
- # Redirect all .php extensions
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_FILENAME} !-d
- RewriteCond %{REQUEST_FILENAME}.php -f
- RewriteRule ^([^\.]+)$ $1.php [L,QSA]
- # Archive Categories
- RewriteRule ^blog/category/([a-zA-Z0-9-/]+)/page/([0-9]+)/{0,1}$ /blog/archive.php?cat=$1&page=$2 [L]
- RewriteRule ^blog/category/([a-zA-Z0-9-/]+)$ /blog/archive.php?cat=$1 [L]
- # Archive Tags
- RewriteRule ^blog/tag/([a-zA-Z0-9-/]+)/page/([0-9]+)/{0,1}$ /blog/archive.php?tag=$1&page=$2 [L]
- RewriteRule ^blog/tag/([a-zA-Z0-9-/]+)$ /blog/archive.php?tag=$1 [L]
- # Blog Posts
- RewriteRule ^blog/([a-zA-Z0-9-/]+)$ /blog/post.php?s=$1 [L]
- # Blog Preview
- RewriteRule ^blog/([a-zA-Z0-9-/]+)/preview$ /blog/post.php?s=$1&preview=all [L]
- </IfModule>
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.
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. -
Thanks, Hussein.
Figured it out just before you posted. *le sigh*
-
Here is the code.
Code- <perch:before>
- <ul class="things-to-do grid grid--2cols--medium half-three--bottom">
- </perch:before>
- <li class="thing-to-do card card--<perch:content id="perch_item_index" type="hidden">">
- <article class="todo__excerpt card__excerpt">
- <h3 class="todo__heading card__heading"><a href="<perch:content id="_page" replace=".php|" />"><perch:content id="title" /></a></h3>
- <p><perch:content id="snippet" type="textarea" striptags="true"></p>
- <a class="card__anchor anchor--<perch:content id="perch_item_index" type="hidden">" href="<perch:content id="_page" replace=".php|" />">
- <figure class="todo__img card__img img--<perch:content id="perch_item_index" type="hidden">">
- <perch:if exists='image'>
- <img class="img lazyload script" src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" data-src="<perch:content type="image" id="image" label="Featured Image">" data-sizes="auto" alt="<perch:content id="title" />">
- <perch:else>
- <img class="img lazyload script" src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=" data-src="https://static.cliftonheritage.net/uploads/jaws-beach-clifton-heritage-national-park.jpg" data-sizes="auto" alt="Jaws Beach">
- </perch:if>
- </figure>
- </a>
- </article>
- </li>
- <perch:after>
- </ul>
- </perch:after>
-
I was able to hide the error messages using php.ini, but I would still like to know if there is something that I can do for this error.
-
This warning can be seen at https://cliftonheritage.net. 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:PHP- <?php
- perch_content_custom('Attraction Content',[
- 'count' => 5,
- 'sort-order' => 'RAND',
- 'page' => '/plan-your-visit/places-to-go/*',
- 'template' => '_places-to-go.html',
- 'each' => function($item) { $item['title'] = perch_page_attribute('pageTitle', ['_id' => $item['_pageID']], true); return $item; }
- ]) ?>
This is what I get from debug. It's on my MAMP server, but nothing's printing out to the screen.