Jump to content

Kiwi Chris

  • Content Count

  • Joined

  • Last visited

  • Days Won


Kiwi Chris last won the day on November 13 2017

Kiwi Chris had the most liked content!

Community Reputation

155 Excellent

About Kiwi Chris

  • Rank
    Full Member

Profile Information

  • Location
    New Zealand

Recent Profile Visitors

1,046 profile views
  1. What I had to do was create two websites with webfaction, one using HTTP and one using HTTPS Go to Domains/Websites, then Websites In the HTTPS site, just use the standard Processwire .htaccess and make sure you've got the site set to use HTTPS. Create another site, using static/CGI/PHP template will do with the same domain name, but make sure it is using HTTP (not HTTPS) and in that one add the code you posted to the .htaccess file of the HTTP site.
  2. I've checked what $event->argument(0) is returning, and it actually is the page the repeater is used on, even though that page doesn't directly have the field 'bom' as that is only used in the repeater itself, so even though the repeater item is technically a page in its own right, my hook is picking up the page the repeater is on anyway. My filter seems to be working as expected now. I think the issue arose because previously I was using a pagetable instead of a repeater, but the client didn't like the presentation, and found a repeater more intuitive. The client only needs a few items, sometimes only one, so a repeater makes sense. With the pagetable, I did need to refer to the parent, and with the repeater items technically being pages, I assumed I needed to do the equivalent, but it turns out that with repeaters the page they're used on is the page returned by the hook.
  3. I'm trying to apply a custom filter on a page field within a repeater via ready.php like so: $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { if ($event->object->hasField == 'bom') { $parent = $event->arguments(0)->page->getForPage(); } // Filter criteria ... } The problem is I get "Call to a member function getForPage() on null" on the line: $parent = $event->arguments(0)->page->getForPage(); Any idea what I'm doing wrong?
  4. I have a role that has page edit, view, and clone permissions on a specific template. If a page using the template is locked by a user in a role with lock/unlock permissions on the template , the only button alongside it in the page tree is view, for users who don't have lock/unlock permissions. If however, I also give the role page-lock permission on the template, they then get additional buttons, edit, copy, and unlock. I don't actually want to give this role unlock permissions, but I do want the copy (clone) button to display alongside the page in the page tree. Elsewhere, I've discussed how I've worked out how to create a hook to unlock the copy, but I want to keep the original page so a user without lock permissions can't unlock from the page tree it to make changes. Question: What method should I hook into to intercept any attempt to change the lock status?
  5. /* * Example of how to clone a locked page, remove the lock on the copy, and clear the value of a field in the copy. * Reset stockCode Field when copying a page using a specific template, also remove locked status. * This code is included in the /site/ready.php file. */ $wire->addHookAfter('Pages::cloned', function($event) { /* * Important: The event arguments include both the copied page and the newly created page. * Don't use $event->arguments('page') as this returns the page that is being cloned rather than the cloned copy. * Instead use $event->arguments(1) which correctly refers to the new copy. */ $currentPage = $event->arguments(1); if ($currentPage->template == 'bom') { $currentPage->stockCode = ''; $currentPage->status = $currentPage->status & ~Page::statusLocked; //probably better to use removeStatus(Page::statusLocked) $currentPage->save(array('quiet' => true)); } }); Here's my documented example of how I got this to work.
  6. I want to be able to allow users with page clone rights the ability to clone locked pages with specified templates to a new unlocked copy, but without letting them edit the locked page. It looks as though I have the right permissions set to allow them to copy a page, but I need to add a hook in the /site/ready.php to unlock a page after it's copied. What method should I hook into? Edit: Figured it out. AddHookAfter Pages::Cloned. I had to be careful to pick the right argument though so that I was modifying the cloned copy and not the page that the copy was made from.
  7. From what I understand, you want to list comments from each product page on the product brand page? Comments documentation is here: https://processwire.com/docs/modules/guides/comments/ If you look at the section in the docs titled OPTIONAL : Generating your own output it has this example code: foreach($page->comments as $comment) { if($comment->status < 1) continue; // skip unapproved or spam comments $cite = htmlentities($comment->cite); // make sure output is entity encoded $text = htmlentities($comment->text); $date = date('m/d/y g:ia', $comment->created); // format the date echo "<p><strong>Posted by $cite on $date</strong><br />$text</p>"; } Of course you can always replace the $page variable in that example with your own variable that returns a page, so you could do something like: $brandProducts = $page->children(); $foreach($brandProducts as $product){ foreach($product->comments as $comment) { if($comment->status < 1) continue; // skip unapproved or spam comments $cite = htmlentities($comment->cite); // make sure output is entity encoded $text = htmlentities($comment->text); $date = date('m/d/y g:ia', $comment->created); // format the date echo "<p><strong>Posted by $cite on $date</strong><br />$text</p>"; } } If your products aren't children of a brand, but simply have a brand field set using a page reference field for example, you'd need to use a selector instead to populate $brandProducts eg $brandProducts = $pages->find("brand={$page->brand}");
  8. I've found this module really useful, and thought I'd share an interesting use case I've come up with for it. I had a client who wanted both the functionality of pageTable, and PageTableExtended, ie they wanted a tabular summary like PageTable provides, but with the option to expand or collapse to display rendered detail from a template like PageTableExtended allows. It turns out, I was able to provide the desired functionality using PageTableExtended, and built in UI-kit classes in the template file I provided to PageTableExtended. <!-- This is the summary section, like displayed by PageTable --> <table class="AdminDataTable AdminDataList uk-table uk-table-divider uk-table-justify uk-table-small"> <thead> <tr> <th>BOM</th> <th>Cases to produce</th> <th>+/- or exact</th> <th>Notes</th> </tr> </thead> <tr> <td><?= $bom->title ?></td> <td><?= $page->cases ?></td> <td><?= $page->exact ?></td> <td><?= $page->notes ?></td> </tr> </table> <!-- Toggle to display detail section --> <a herf="#" class="toggleRenderedLayout"> <i class="toggle-icon fa fa-angle-right"></i> </a> <span class="renderedLayoutTitle">BOM Details</span> <!-- Detail section, hidden by default, using built in ui-kit css. --> <div class="renderedLayout hiddenOnStart"> <div uk-grid uk-margin-small-top> <div class="uk-width-1-3 uk-margin-small-top"><strong>Wine Variety </strong><?= $bom->wineVariety->title ?></div> <div class="uk-width-1-3 uk-margin-small-top"><strong>Brand </strong><?= $bom->brand->title ?></div> <div class="uk-width-1-3 uk-margin-small-top"><strong>Market </strong><?= $bom->market->title ?></div> <div class="uk-width-1-1 uk-margin-small-top"><strong>Orientation </strong><?= $bom->orienation->title ?></div> ... </div> </div> Screenshot, showing the tabular summary, with the detail section expanded.
  9. In the RTE, when inserting a link, there are several input fields that can be used to select a page, including a text input field that will auto-complete with pages on the site. When inserting an image, there is only an option to navigate the page tree. (equivalent to the second input option 'Select Page...' on the Insert Link screen from the RTE. When inserting an image from another page buried somewhere in the page tree, if you know the name of the page, it would often be quicker to use an auto-complete text field than 'Select Page...' option. It would be nice if the image insertion dialog offered the same functionality as the link insertion dialog so that when selecting a page it's possible to choose either to navigate the page tree, or have a text auto-complete field.
  10. Conditionally 2, provided the collapsible option is available. One of the things I like about Processwire is that it plays nice with mobile screens. Some other CMSs are clearly designed for desktops or large tablets only, but Processwire will work even on a smartphone. I can't say how often I'd actually use it on a phone, but it would be nice to have the option. I actually can think of a case where having the backend mobile friendly would be handy. I was at a market last year, and someone didn't have any cash, but did have a credit card. Of course the front end of my site is mobile friendly anyway, but it could be handy to have the backend mobile friendly too.
  11. If for any reason, you can't get terminal access, you can add the php code to any template that already exists in the /site/templates directory and then view any page based on the template to trigger it. You won't require the first require line in that case, and don't forget to remove the password reset code again afterwards.
  12. Beat me to it. It's one of the nice things about Processwire that the admin is simply a UI on top of the API, and anything you can do via admin, you can also do easily via a script.
  13. I'm trying this option, but I can't seem to get it to work. I've tried: public function ready() { $this->addHookAfter('Page::render', $this, 'updatePageViews'); $page = $this->page; } public function updatePageViews($event) { /** @var Page $page */ $page = $event->object; // don't add this to the admin pages if ($page->template == 'admin') return; if ($page->hasField('pageViews') and $this->user->isGuest) { //Update the number of page views for current page, but only visitor views not admin. $page->of(false); $page->pageViews ++; $this->pages->saveField($page, 'pageViews'); $page->of(true); } } and this way: public function ready() { $page = $this->page; if ($page->hasField('pageViews') and $this->user->isGuest) { //Update the number of page views for current page, but only visitor views not admin. $page->of(false); $page->pageViews ++; $this->pages->saveField($page, 'pageViews'); $page->of(true); } } But neither of them seem to do anything with template caching enabled. Any idea what I'm doing wrong? Edit: I found the problem isGuest needs brackets, ie isGuest()
  14. Update: In addition to the modules previously mentioned, the site now uses Padloper to add shopping cart functionality, and PaymentStripe and PaymentInvoice modules. I've also made some modifications to the MapMarker module so that I can use KML files from a separate files field as map overlays. This is really handy, as I can use Google Earth to define paths and areas that I can overlay on the map, which I can export and display with Processwire. In the process, of implementation with the payment modules, I discovered an issue with module dependencies and the modules cache in the database, which I've discussed and resolved here: https://processwire.com/talk/topic/19606-class-not-found-error/?tab=comments#comment-170031
  15. This was coming from an old CMS. I used Source: index.mvc?ArticleID={id} Destination: [[wid={id}]]
  • Create New...