Posts by marc

    Site settings, global configuration, site attributes, shared settings, website config...


    Whatever you would like to call them, but a native way to store global settings for a site. I tend to have a shared region setup for each site build, where I store all the necessary details and access these throughout the site.


    Example settings include:

    • Site title
    • Site description
    • Default images:
      • OG image
    • SEO:
      • Title prefix
      • Title suffix
    • Code snippets:
      • Header
      • Footer
    • Contact details:
      • Address
      • Telephone
      • Email
    • Social (Repeater):
      • Platform title
      • Platform url
      • Platform icon
    • Site notification settings
    • Other globally defined aspects


    A more formal method would be great, of course using Perch’s flexibility and structured approach. You could see a familiarity to the functionality of page attributes but for the whole site.


    Super useful!

    Not sure if I can pick just one, here are a couple of my more recent sites:

    hus_hmd we do already utilise the result source within the results template.


    So the main issue is that the site uses the branched method. Each site has its own blog which uses the multiple blogs feature available in runway to manage. These have been named EN etc. As seen in the previous screenshot.


    The problem that arises in the search results is that all blog posts are seen the same, a post that features on the DE blog might crop up search results on the EN site search along with EN blog posts. The issue is that from the result url that is no way to know that a blog post is from the DE blog to filter out. The url will always appear /en/latest/german-blog-post/


    Thinking about it, I’m not sure if updating the blog post url in settings may help.


    Does that make sense?

    Hey buddy,

    Just a thought, return the categories and pass in to the pages navigation function using the data option. This may help getting the categories in with the pages navigation/templating, you would then need to utilise perch conditionals to show the categories under the nav item required. Or use in conjunction with the idea that Byron Fitzgerald has suggested.


    PHP
    1. $categories = perch_categories([
    2. 'set' => 'my-category-set',
    3. ], true);
    4. perch_pages_navigation([
    5. 'data' => [
    6. 'categories' => $categories,
    7. ],
    8. 'template' => 'template.html',
    9. ]);

    It's one of those things that i'm pretty sure I have come across in the past before with runway and rewriting. Although I think it was a similar scenario with collections instead of the blog app.


    I think in the past I have passed in the cat/section slug into the function using data similar to below and built the url up, but it's good to know that the url tokens are available to use.


    Thanks for the clarification hus_hmd :thumbup:

    HTML
    1. <perch:if exists="paging">
    2. <div class="pagination">
    3. <perch:if exists="not_last_page">
    4. <perch:if exists="cat">
    5. <a href="/journal/category/<perch:content id="cat" type="hidden" />/<perch:content id="next_url" type="hidden" encode="false" rewrite="{page:%s/}" />" class="load-more button button--primary button--l" role="button">Show more</a>
    6. <perch:else />
    7. <a href="/journal/<perch:content id="next_url" type="hidden" encode="false" rewrite="{page:%s/}" />" class="load-more button button--primary button--l" role="button">Show more</a>
    8. </perch:if>
    9. </div>
    10. </perch:if>

    If I manually navigate to /en/news/section/events/2/ the correct blog posts display.


    The debug has the following:


    Hi all


    Got a blog setup on Runway which uses sections. Standard index page setup which either displays posts for a section or all.


    Can't seem to get the paging to rewrite the section. The link generated just seems to output the next page number without the rewritten section.


    Expected url

    /en/news/section/events/2/


    Current url

    /en/news/section/2/


    Would it make any difference to have a section.php master page instead of using a conditional?

    Routes setup on page

    en/news/section/[slug:section]/[i:page]

    en/news/section/[slug:section]

    en/news/[i:page]

    blog/index.php

    blog-grid.html

    Managed to fix the issue. It turns out that a blog article had to be attributed to a blog section to appear in the results.

    I have never come across this before, just wondering if anyone else had?

    Hey Jakeness,


    No worries, this was before hus_hmd released a slick filter for phone numbers. But here is how I had it setup:

    HTML
    1. <a href="tel:<perch:content id="phone" type="text" filter="space" />">
    2. <perch:content id="phone" type="text" label="Phone number" required="true" order="1" />
    3. </a>

    Correct me if I am wrong but it appears you can add multiple instances of the re-dispatch function:

    Thanks Hussein, that works.


    On a couple of forms on the site I had two apps in the forms apps="perch_forms boldr_subscribe" attribute prior to adding the recaptcha app.


    Just tried re-dispatching to both but I seem to get errors, I'm guessing it's not possible?


    Code
    1. [type] => 2
    2. [message] => call_user_func() expects parameter 1 to be a valid callback, function 'perch_forms boldr_subscribe_form_handler' not found or invalid function name
    3. [file] => /Users/Marc/Dropbox (Boldr)/Work/Chestnuts/Online/Website/Build/cms/core/lib/api/PerchAPI_SubmittedForm.class.php
    4. [line] => 452

    After a recent increase in spam submissions on a site, I have decided to ditch the honeypot method and create a simple app to validate a ReCaptcha v3 response in a form.


    All works apart from a test case when you submit a form successfully and then you refresh the page so the form submits again. The form throws a general perch error using $SubmittedForm->throw_error('spam', 'recaptcha'); because rightly so the g-recaptcha-response is now invalid as the response can not be used - but the form is successfully processed and stored by the forms app.


    The recaptcha field must be pulling the data through from the previous submission? Anyway debug and code below, any help appreciated - I did wonder whether it would make more sense to write a custom form validator instead and just add that to the recaptcha field.

    Debug output after page refreshed (form error along with the recaptcha response):

    My code

    In my form template I have the app attribute set on the form as app="boldr_recaptcha perch_forms" so that my app is passed the form first. I have a hidden input which is populated with the ReCaptcha javascript ready for submission <perch:input id="g-recaptcha-response" type="hidden" label="Recaptcha" />

    Snippets from my apps code: