Jump to content

thetuningspoon

Members
  • Content Count

    646
  • Joined

  • Last visited

  • Days Won

    3

thetuningspoon last won the day on May 18 2020

thetuningspoon had the most liked content!

Community Reputation

554 Excellent

3 Followers

About thetuningspoon

  • Rank
    Hero Member
  • Birthday 11/03/1986

Contact Methods

  • Website URL
    https://si.design

Profile Information

  • Gender
    Male
  • Location
    CT, USA
  • Interests
    Design, Programming, Tiny Houses

Recent Profile Visitors

12,995 profile views
  1. I'm curious what the rationale is for the default behavior of a page save uncaching all pages in the system, as this sometimes causes problems when editing and saving more than one page during the same request. I'm finding myself having to add ['uncacheAll' => false] to most of my page saves. But if there is some important reason for clearing the cache, I want to be aware of it!
  2. Hi @antpre. Making the module permissions-aware may be possible, but it would be a bit tricky since it would involve hooking the markup for each of the inputfield option types and injecting a data attribute to signify whether the page is editable/addable. If I get some free time I will see if this is possible. This sounds like it would be an issue with any modal window in the back end. Unfortunately, iframes are basically unusable on iOS. On all of my sites that use iframe modals, I use browser detection to disable them on iOS.
  3. @horst Thank you! The image access control was indeed the problem. At some point the client made a copy of the page and trashed the original, and the clone was still referencing the images on the original page. Is this how it's supposed to work? It seems like if the page clone clones all of the images on the page, it should also update the image references inside of its textareas 🧐
  4. This is a weird one. I have a page with a repeater matrix field on it. Several of the items have CKEditor fields with images in them. When I view the page while logged in, the images are visible. When I log out, all but one of them is stripped from the output. I double checked that the IDs of the repeater items remain the same--they do. The image tags are completely absent when I view source. I used to have ProDrafts installed, but have now remove it. I have ProCache installed, but temporarily disabled it to test this. I'm at a loss. Any ideas?
  5. Hi @bernhard, We've been running up against the limitations of ProcessWire's native method of handling subfields in selectors. Basically, every subfield in a selector results in a separate query that runs to return all IDs that match the subfield, and then those IDs are used in the where of the final sql query (as opposed to joining the tables and then doing a where on the data all in a single query). This fails at scale because the individual subfield queries start returning so many page Ids that memory is exhausted or MySQL even crashes. There are ways to work around this in some cases by using separate selectors instead of subfields, but it's not terribly elegant. My question is, can we use RockFinder to solve this problem? In this particular use case, we would still want to end up with Pages in the end. I am guessing that using subfields in a RockFinder selector would behave the same way as it does in native PW (I assume RockFinder just gets the final query that PW creates for it--which may have taken multiple queries to construct--and proceeds from there). But if the join function would allow us to limit results based on the values of subfields all in a single query, then that would be golden. At that point all we would want back from RockFinder would be an array of page ids, which we could pass to Pages::getById() to get the pages back. Perhaps a method call for doing this is worth putting into RockFinder? This would be much more efficient than using the callback since it would be one SQL query to get all the pages. Another thing which I mentioned back with RockFinder1 (and implemented locally) is the option of getting a WireArray of WireData objects instead of standard objects or a plain array. This is still way faster than Pages but allows you to use runtime selectors on the results. Anyway, thanks for your work on this and looking forward to your thoughts.
  6. I wrote this a while back for my company's internal documentation and just realized it might be a benefit to others on the forum, so here it is! Checking whether a field was changed To check whether a specific field was changed you can do $page->isChanged(‘field’). This can only be done before Pages::save, since the save clears change tracking by default. Getting the values of a page before they were changed, from within a hook before Pages::save Method 1: The hacky way $clone = clone($page); $e->wire('pages')->uncache($clone); $oldP = $e->wire('pages')->get($clone->id); $oldP then represents the page and all its values as they were before any changes were made. Again, this will only work for hooks that run prior to Pages::save. Method 2: Using change tracking to get the old values If change tracking is set to track values, then the above is not necessary. In this case, calling $page->getChanges(true) will return an associative array of fields that changed and each field's prior value. Note that the value itself is also an array, since it is designed to be able to track multiple changes over the course of a single request/response cycle. Tracking of values is turned off by default (for efficiency sake), and there is no global switch to turn it on and off. To enable tracking of values, you must call $page->setTrackChanges(Wire::trackChangesOn | Wire::trackChangesValues) before any changes are made to the page that you want to track. Here is an example of how you can enable value tracking in ProcessWire's page editor: $this->addHookBefore("ProcessPageEdit::execute", null, function($e) { $p = $e->pages->get((int)$e->input->get('id')); if($p->template == 'event-registration') { $p->setTrackChanges(Wire::trackChangesOn | Wire::trackChangesValues); } }); Running hooks on both page saves and field saves Please note that using the following hooks is preferable if you want the hook to run both when individual fields are saved as well as the whole page: Pages::savePageOrFieldReady https://processwire.com/api/ref/pages/save-page-or-field-ready/ (for before a save) Pages::savedPageOrField https://processwire.com/api/ref/pages/saved-page-or-field/ (for after a save) Getting changes in a hook after Pages::save Note the $changes parameter passed to Pages::saved and Pages::savedPageOrField allows you to check which fields were changed during the save, even though the save is already completed. Using this is sometimes preferable to using a Pages::saveReady or Pages::savePageOrFieldReady hook since you don’t have to worry about the page cache or something else in your code preventing the original save from completing. A $values array is also provided, which is populated only if change tracking is set to track values (see above) Page cache issues when hooking before Pages::save Page cache issues may occur when you try to save another page inside of a before save hook (Pages::saveReady or Pages::save). A page save normally clears the entire page cache, which means any page fields on the page you were originally trying to save will have their values reset. So if you have to save another page inside of a before save hook, just use $page->save([‘uncacheAll’ => false]) to prevent the cache from being cleared. Preventing hooks from running on a particular save To prevent any hooks from running on a particular page save, you can use $pages->save($page, [‘noHooks’ => true])
  7. Temporarily comment out the following line in Page.php: throw new WireException("You may not modify '$key' on page '{$this->path}' because it is a system page"); This will allow you to clone the home page via the API: $homePage = $pages->get('/'); $pages->clone($homePage, $homePage, false);
  8. Temporarily comment out the following line in Page.php and you will be able to clone the home page via the API: throw new WireException("You may not modify '$key' on page '{$this->path}' because it is a system page");
  9. At my job we have our own profile that we've created using the most recent version of the profile exporter (v3). Recently we added some new features including some repeater matrix fields to the site that the profile is based on, and re-exported the profile. Now when we go to install the site (submit the database configuration details), the installation times out. I tried upping the timeout in php but it just chugs and chugs. I tried installing using both the current master (3.0.148) and the current dev (3.0.153) version. The blank profile that comes with PW installs no problem. One point of interest here is that we typically use InnoDB for our sites, but the site that is the source of the profile was MyISAM. I tried installing the profile using MyISAM, and it WORKED. So my thought was that maybe if I converted the profile source site to InnoDB and re-exported, then I could install the site with InnoDB. Unfortunately, after doing so, now I cannot install the profile with either InnoDB OR MyISAM (both just hang). Any thoughts on what could be at the root of this, or some way that we could troubleshoot it?
  10. For anyone stumbling on this old thread, it looks as though Ryan has now addressed this issue (though I have yet to have a chance to test it):
  11. @gmclelland UI Blocks is a front-end output strategy that we built at Solution Innovators. Not in the module directory yet due to a lack of good documentation. But I'm getting close to having that ready 😁
  12. Thank you Ryan! The slow rebuild of the page parents table after doing a clone is something that we've run into on one or two of our projects and I'm delighted to hear that this has been addressed.
  13. I can't be limited to just 5... ListerPro MarkupSitemapXML ProFields Table ProFields RepeaterMatrix AdminPageFieldEditLinks AdminModalception Decimal TextformatterVideoEmbed ProCache ProDrafts UI Blocks
  14. Ok, I'll admit it, even I have a hard time remembering the name of AdminPageFieldEditLinks 😂 I'm glad it could at least serve as inspiration for this nice enhancement!
  15. Happy to help! Let me know if you want me to go into more detail on any of these and I will do my best.
×
×
  • Create New...