Posts by jsphpndr

    JayW, I was able to find the solution. I had already tried with the allowempty attribute, but that was not what I was looking for as it was still a valid option.

    Disabling the first <option> with the disabled attribute allows you to have filler text that will force users to pick an option and ensure there is a message available to inform the user what it is they're supposed to do.

    I got the solution. I added it to the forum here: Disabling and selecting first <option> in <perch:input type="select">?

    Thanks for all the help. :)

    Hey there,


    Just wanted to make this little bit of information available on creating a <select> element to everyone and anyone who may need it.

    The documentation is here: https://docs.grabaperch.com/templates/field-types/select/

    If you need, to disable the first option, use an exclamation mark (!) before the option:

    Code
    1. <perch:input id="course_time" type="select" label="Time of course" options="!AM, PM, Full day, Evenings" required>


    If you want to have that option selected, use the value attribute along with the corresponding option value:


    Code
    1. <perch:input id="course_time" type="select" label="Time of course" options="!AM, PM, Full day, Evenings" value="AM" required>


    That is all. :)

    I'm currently using the method provided over in the docs: https://docs.grabaperch.com/addons/shop/examples/no-account/


    Incustomer_create_passwordless.html I modified the template as follows:


    When submitted and I look at the order area, pickup_location, tour_date, andterms-conditions are neither stored with the order (where it's supposed to be) nor the member profile.

    I tried utilizing cart-property in this template but it through an error.

    How can I collect and store these bits of information as a part of the customer's order?

    Hey Muscateer,


    If you need some help, I'll be available later today. It'd be interesting to see what's going on.


    Curiousity has gotten hold of me. haha


    Can I ask why you're usingshort_open_tags in production?


    PHP
    1. <? include "file.php"; ?>
    2. VS
    3. <?php include "file.php"; ?>

    Mikeymu, you're in luck... if you're willing to make some adjustments to Perch's core files.

    This is part of my CSP and should provide you everything you need for the login and dashboard.

    I'm generating nonces in .htaccess but you can modify the below to whatever your situation is.

    Once you've done this, go to the /perch/config/config.php and define a constant with the nonce value:

    Code
    1. define('SECURITY_NONCE', $_SERVER[X_HTTP_NONCE]);

    Then you're going to go into /perch/core/ and you're going to modify those inline <script> and <style> tags in /perch/core/layout/top.php and /perch/core/layout/login/top.php adding the nonce attribute and echoing your constant:

    PHP
    1. <style nonce="<?php echo(SECURITY_NONCE); ?>"></style>
    2. <script nonce="<?php echo(SECURITY_NONCE); ?>"></script>

    There is a caveat in that anytime there's an update you will have to make these modifications again. Hopefully, this helps. If you have any questions, don't hesitate.

    Gareth S

    Another request that I have while trying to create a filter is realizing that the editors' default image button/shortcode does not include the image width and height. Can we add these attributes and their values to these image outputs generated by the editors.


    Code
    1. This:
    2. [cms:asset 18 title="This is an image"]
    3. Renders:
    4. <img title="This is an image" src="https://example.com/uploads/this-is-an-image.jpg" alt="This is an image">
    5. What it should be to meet current web standards:
    6. <img title="This is an image" src="https://example.com/uploads/this-is-an-image.jpg" width="1920" height="1080" alt="This is an image">

    Gareth S,

    To a point I made earlier with regard to nonces for Perch, there doesn't seem to be much in the way of work for this. I just recently made an adjustment to the core templates using a constant in the config file and just echoing it out. This is problematic, because when there's a new update, I'll have to go back and update it again.

    Maybe something like this can be done...


    The developer can choose how they wish to generate nonces and the CMS will work with or without a CSP.

    Gareth S, there are some things that I'm sure are not coming to mind right now, but for sure, upgrades to the UI and security.


    First the UI needs some work, whether on desktop or mobile. More importantly, there are lots of internal scripts and styles used that are disallowed with a strong CSP. I would ask for a way to ensure that the backend can have a strong CSP enforced with nonces and hashes (if needed). Perhaps a constant like:


    Code
    1. define("PERCH_NONCE", $_SERVER['HTTP_X_NONCE']);


    This way it could be used on the front and backend.

    Is there a way to change the webmentions filepath in Perch?

    The default code...

    Code
    1. perch_blog_post_webmention_endpoint(perch_get('s'));


    currently, returns the following:

    Code
    1. <link href="/perch/addons/apps/perch_blog/endpoint/?pid=16" rel="webmention">


    I don't think this is the best approach. Is there anyway we could modify this path to something like:

    Code
    1. <link href="/blog/endpoint/?pid=16" rel="webmention">


    Something of this nature which basically doesn't expose backend directory structure.

    Any help is greatly appreciated, even if the answer is "no". At least, I'll know not to use it.

    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
    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:

    perch-html.png

    And here's the output:

    perch-as-rendered.png

    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:

    perch-settings.png

    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.


    PHP
    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.


    perch-debug.png