Jump to content

Peter Knight

Members
  • Posts

    1,358
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by Peter Knight

  1. Thanks everyone.

    This works great. I thought I'd have to make something much more complex.

    <?php
    echo "<a href='" . ($page->prev("template=staff-detail")->path ?: $page->siblings("template=staff-detail")->last->path)."'><i class='fas fa-arrow-left'></i></a>";
    			
    echo "<a href='" . ($page->next("template=staff-detail")->path ?: $page->siblings("template=staff-detail")->first->path) . "'><i class='fas fa-arrow-right'></i></a>";
    			 ?>

    The colon in the two echo statements seems to be some kind of shorthand for if/else. I hadn't seen it before so thanks for the tip.

    👍

     

    • Like 2
  2. 32 minutes ago, Jan Romero said:

    Ah, nice, definitely! I was hesistant to use the WireArray first() and last() functions, because I wanted to avoid loading all siblings. Not sure if that’s really a concern, though?

    There will probably only be 10 siblings so OK if you're approaching from a performance point of view

  3. Hi

    I have series of staff pages and each page has a back and forward arrow to allow you to jump to the previous or next person

    • Staff overview
    • Staff 1 (template=staff-detail)
    • Staff 2 (template=staff-detail)
    • Staff 3 (template=staff-detail)
    • Staff 4 (template=staff-detail)

    I had it all working as follows

    <!-- START: Next and Back for staff -->
    <?php
    if($page->prev("template=staff-detail")->id) {
    echo "<a href='{$page->prev->path}'><i class='fas fa-arrow-left'></i></a>";
    } ?>
    			 
    <?php
    if($page->next("template=staff-detail")->id) {
    echo "<a href='{$page->next->path}'><i class='fas fa-arrow-right'></i></a>";
    } ?>
    <!-- END: Next and Back for staff -->

    However, I now want to change the next and back arrows to infinitely loop through siblings.

    IE

    1. if you get to Staff 4 and click next arrow, you get to Staff 1
    2. if you get to Staff 1 and click previous arrow, you get to Staff 4

    I couldn't find anything in the docs which allows for some kind of infinite loop? Can anyone guide me on how to approach this?

    Many thanks

    P

    CleanShot 2022-05-31 at 15.54.36@2x.png

  4. Does anyone know if this Module works in RepeaterMatrix or what I might be doing wrong to get a Call to undefined function wireRenderFile() error?

    Used within the template itself (and outside Matrix), I can successfully render my file using the following

    <?php $myfile = $page->fieldtypeselectfile; ?>
    <?php echo wireRenderFile("$myfile");?>

    However, when I create a Matrix Repeater field called Element_Picker.php and add that same code into

    site/templates/fields/matrix/Element_Picker.php

    I get an error

    Fatal Error: Uncaught Error: Call to undefined function wireRenderFile() in site/templates/fields/matrix/Element_Picker.php:3
    
    #0 wire/core/TemplateFile.php (327): require()
    #1 wire/core/Wire.php (414): TemplateFile->___render()
    #2 wire/core/WireHooks.php (951): Wire->_callMethod('___render', Array)
    #3 wire/core/Wire.php (485): WireHooks->runHooks(Object(TemplateFile), 'render', Array)
    #4 site/modules/FieldtypeRepeaterMatrix/RepeaterMatrixPage.php (284): Wire->__call('render', Array)
    #5 site/templates/fields/matrix.php (3): RepeaterMatrixPage->render()
    #6 wire/core/TemplateFile.php (32 (line 3 of site/templates/fields/matrix/Element_Picker.php)
    
    This error message was shown because: you are logged in as a Superuser. Error has been logged.

    Thanks. Much appreciated as always. 
     

     

  5. Hi @Martijn Geerts
    Great Module. Thanks for contributing this to the community.
    I think I've found a bug using ProcessWire 3.0.184

    If I specify a subfolder such as blocks/ or just blocks, I can see the list of available files in the fieldtypeselectfile dropdown.
    But on the frontend, I get an error as follows. I can see that the blocks subdirectory isn't being recognised.
     

    Quote

    Error: Exception: Filename doesn't exist: site/templates/PK-CTA-2button.php (in wire/core/TemplateFile.php line 177)

    Happy-ish to just work off the main templates folder but for house-keeping purposes, I'd love to specify a sub-folder.

  6. 18 hours ago, bernhard said:

    Yes, you can use InputfieldTextTags https://processwire.com/blog/posts/pw-3.0.177/

    But it would be a lot easier to use HannaCode or a custom Textformatter module which replaces [file=foo-bar.php] with the content of the file foo-bar.php

    Thanks @bernhard
    I've been trying this and much to my surprise, I have it working as follows. Have yet to try it within a Repeater Matrix for the moment.

    <?php $myfile = $page->fieldtypeselectfile; ?>
    <?php echo wireRenderFile("$myfile");?>

    I did find a bug whereby this only seems to scan files within the template folder and not a custom directory but I'll mention that on the main Module thread.

    Thanks.

  7. 20 hours ago, aagd said:

    In the RepeaterMatrix field create two repeater matrix item types: cta1 & cta2. They don't even have to have any fields, i guess.

    In the template file that should output the repeater items you can output them like this:

    <?php
    
    foreach($page->repeater_matrix_field as $item){
    
      if ($item->type == "cta1"){
        echo wireRenderFile("Call-to-Action01.php");
      }
    
      if ($item->type == "cta2"){
        echo wireRenderFile("Call-to-Action02.php");
      }
    }
    
    ?>

    RepeaterMatrix is a pro module, though. Not Core.

    Thanks @aagd. Good idea and certainly something I'm about to explore. I used 2 examples but I'll probably at some stage end up with a lot more. My concern is about scalability here and having to create a field to associate with each file. Ideally I'd love a file select field that I can simply point at a directory.

  8. Hi 

    Is there a field type in the Core which will allow be to select one (or more) files within the PW file system?

    For context...

    I want to create two stand-alone PHP files which contain simple HTML as follows

    • Call-to-Action-01.php would be <h2>Call us</h2>
    • Call-to-Action-02.php would be <h2>Email us</h2>

    These would be stored within the PW /templates directory (I think).

    I then want to use RepeaterMatrix to select one or both and output them into my template where necessary.

    I was then looking at the $files->render() method and have the following working

    <?php $string = $files->render($Call-to-Action01.php); ?>

    So that's a good start but now how to select ?

    Thanks 👍

     

     

  9. On 1/23/2022 at 12:01 AM, Guy Incognito said:

    Thanks 😊.

    I will check out RockSEO. The thing that has kept us on MarkupSEO to date is the simplicity for implementation and also for clients. Combined with the changes you’ve made previously it’s pretty effective at doing what it needs to.

    I’ll have a think if there’s anything else that can be done to improve it further.

    Is RockSEO an upcoming Module by the community or a paid Pro Module?

  10. @Mike Rockett

    I'm getting an error on an install as follows:
     

    Quote

    Failed to init module: ProcessJumplinks - SQLSTATE[42S21]: Column already exists: 1060 Duplicate column name 'last_hit'

    It only affects the admin/back-end but wondered if there was a sensible way to fix?

    The only change I made recently to the Module was to stop logging 404 errors and possibly an upgrade of the Module too.

    Many thanks

     

     

  11. Hi Mike.

    I was having issues with a site recently where the database seemed to baloon in size (98 MB) and I tracked it down to the Jumplinks Module.

    I think the culprit is the 404 monitor which only displays the latest 100 but might possibly keep a record of everything?

    After logging into the Jumplinks admin area and clearing the 404 records, the table is back down to a few kb.

    Actually, my entire database is down from 103 MB to 5 MB

    Is there a way to prevent this instead of manually clearing the 404 recording? Assuming this is the culprit...

    Thanks

     

    • Like 1
  12. In MSN, we have the ability to adjust the inner template by editing this:

    <div class="uk-navbar-dropdown"><ul class="uk-nav uk-navbar-dropdown-nav">||</ul></div>

    This affects all the drop-down menus on my page (which is great).

    But what is you want to just target the output of a single dropdown?

    I have a requirement to inject just one of my drop down menus with a 'special link' (just some html)

    Quote

    Fruit
    - page 1
    - page 2
    - page 3

    Colours
    - page A (ID 1398)
    - page B
    - page C
    - special link

    I made some progress by creating a conditional check

    <?php
     if($page->id == 1398)
    	$txt3 = "special link";
     ?>

    and then adjusting the drop down template to...

    <div class="uk-navbar-dropdown">
      <ul class="uk-nav uk-navbar-dropdown-nav">||
      '.$txt3.'
      </ul>
    </div>

     but then I realise that it injects my special link into all the drop downs and I just want to appear for the drop down of Colours.

    Can anyone point me in the right direction keeping in mind my basic (very) PHP skills?

    Thanks
    BTW I know @Soma is the author here of the Module but following his beautiful artwork on Instagram, I'm not sure if he's in the web dev industry anymore?

     

     

  13. Hi 
    I have a list of pages all based on the same template but I want to exclude 2 by page ID

    
    $expertises = $pages->find("template=case-type, sort=sort");
    foreach ($expertises as $expertise);

    I know I could change their template or add an exclude checkbox to the template etc

    Wondering if there is a page=not(4989,9877) type of thing in the API to exclude pages by ID?

    I can't find anything in the API docs but think I may be searching for the wrong phrase.

    Thanks

  14. Hey I'm building my first new site in well over a year and am a little rusty on selectors but particularly retrieving sub-fields of selected pages.

    I am trying to output the meta data of a blog post as follows.

    Quote

    Posted by [Person Name], [Job title].

    [Person Name] is just a field with a Page Reference and simple enough.
    [Job Title] is the sub-field within the page that was referenced above.

    I actually have it working with the following:

    Posted by:
    
    <?php
    	if($page->insight_author) {
    	echo $page->insight_author("<a href='{url}'>{title}</a>");}
    ?>
    ,
    <?php
    	$roles = $page->insight_author;
    	foreach ($roles as $role) {
    	echo "{$role->staff_role}";} 
    ?>

    but was wondering how to do this with selector sub-selectors instead. My current code is probably quite 'old school'?

    Thanks

     

  15. Hi all
    I'm moving a site to a new server and getting the dreaded but common error
     

    Quote

    ProcessWire: ProcessLogin: This request was aborted because it appears to be forged.

    I can access the front-end and internal pages so the .htaccess is working. I cannot see any images on the site although I can access them directly if I put their absolute URL into a browser.

    As is this a new VPS, I hunted around for some obvious server-level settings etc which may have been overlooked.

    To rule out any issued caused by a site move, I also tried a fresh install. That fresh install has the same problem when trying to access the front end.

    Quote

    ProcessWire: ProcessLogin: This request was aborted because it appears to be forged.

    I have also been around the forums several times for similar threads and the largely contain recommendations about CHMOD. I believe I have tried most of these too.

    What is the latest thinking about this error?

    Many thanks, P

  16. Can anyone tell me which .htaccess directive might be blocking a site import feature from scanning my public_html folder and listing all files and folders.

    These would be both PW files/folders but also some non PW folders which my PW site references for media.

    Latest .htaccess file on Github

    I can see various options from Section 15 onwards (# 15. Access Restrictions (v301)) but nothing that would block both SSH and FTP scans my VPS site import file uses.

    When I point the same site import tool at a non PW site on the same directory it works.

    I could disable htaccess temporarily but it's a busy and active site.

    Thanks

    P


     

     

  17. Hi Adrian
    I was updating my site a few minutes ago and it started displaying a 500 error. When I turned on notifications, I saw the following error.

    Fatal error: Cannot declare class TracyDebugger, because the name is already in use in /home/p752009485/public_html/site/assets/cache/FileCompiler/site/modules/TracyDebugger/TracyDebugger.module.php on line 19

     

    Is it ok to manually remove the Module somehow?

×
×
  • Create New...