• Content count

  • Joined

  • Last visited

Community Reputation

27 Excellent

About bmacnaughton

  • Rank
    Sr. Member

Profile Information

  • Gender
  • Location
    SF Bay Area
  • Interests
    Photography, reading, cooking. My family. Systems and code that stand the test of time.

Recent Profile Visitors

1,547 profile views
  1. Thank you @Zeka. Perfect answer, with code reference! I am getting more familiar with the code slowly.
  2. When I delete a page name, e.g, /cart/, using the admin interface it goes into trash and gets the name /trash/2573.1.11_cart/ . I see that, with the Pages::trashed hook that the previous page name (previousPage) can be accessed. Where can I more information about what happens when a page is put into trash and what the name means?
  3. I have a hook that creates a page for a subset of the pages on our site. It uses the saved page's name as part of the created page's name. The problem I am having is that my hook, attached to Pages::saved(), is being called even when the page save failed because of missing fields. Is there a way I can tell that the page save failed due to missing fields? Never mind - it does succeed; it just issues warnings about required fields.
  4. What's odd is that PW doesn't take all the data from the array passed to $form->process(). You can argue the CSRF protection is a different function, but that's just internal implementation. And it's easy enough to stuff things into $input->post, so it's not like it prevents forging.
  5. You can stuff the values into $input->post or you can set the HTTP headers, so you can work around it.
  6. I tried the same thing - it was the last way I could think of. I'm not sure why it didn't work but will try again.
  7. Thank you @Robin S. I am going to give this a try - I solved this particular problem by forcing the new entries under the page they are contained by but that is a suboptimal solution.
  8. Thanks Abdus. I have a little different problem - I am looking for the specific page instance that has the field being edited. There are multiple pages based on the template that contains that field. I need to know which specific page instance is the "logical parent", not the set of pages that contain that field, i.e., are instances of the template that includes that PageTable field. To try to make it more concrete: PageA, PageB, and PageC all have the PageTable field Variations. When in the Admin interface PageA is being edited and the user wants to add a variation then they click "Add New" under Variations. At that point an iFrame overlay pops up to enter data for the new PageTable page in Variations. When that PageTable page is saved I need to know that it is associated with PageA. If the PageTable pages were in their default location (children of PageA) then I could just look at parent. But the PageTable pages are all kept in a single directory for grouping purposes. Make sense?
  9. When a PageTable field in a specific template is being edited I need to know the Page that contains the PageTable so I can fill in hidden fields in the PageTable. I can capture the page being edited via: // $this->addHookBefore('ProcessPageEdit::execute', ... public function pageEditExecuteBefore(HookEvent $e) { $p = $e->object->getPage(); if ($p->template !== 'rtw-product') return; // $p is the page being edited } I can intercept PageTable entry being saved: // $this->addHookBefore('Pages::save' public function savePageBefore (HookEvent $e) { $p = $this->wire('page')->id; $page = $e->arguments('page'); $obj = $e->object; $name = $page->name; // page name of PageTable page $template = $page->template->name; // template of PageTable page $parent = $page->parent->name; // parent directory for PageTable items What I am trying to find is the page in which the PageTable field is located. I've also tried having pageEditExecuteBefore() saving $p in $this->context and then accessing that in savePageBefore() but it's a different instance of the class because $this->context is null when it gets to savePageBefore(). I could save the page ID in session, but that seems error prone. Does anyone know how to achieve this?
  10. Thank you. I really appreciate the link and the code being on github. I learn a lot by reading code and yours is very helpful. I've solved the problem for one template but your solution is more general so when the inevitable additional template comes along, I'll most likely move to your module. Thanks for putting it together and pointing me at it.
  11. Do any experts have experience with the level of stability and/or support for turning on $config->advanced? I ask because of the warning at the bottom of the System tab "Please note that all of these system settings are intended for ProcessWire system development (not site development). Use them at your own risk." It provides two facilities that are invaluable to me (maybe because I don't know how to do them any other way). 1) Disable Settings Tab on a per template basis 2) Page Class Name - this makes it tweak a page while relying on the underlying Page class for the majority of functions. Are others using this setting in production? Have you used it over an extended time and seen that it is not changed often or at all?
  12. I'm working in version 3 and can't remove the settings tab using your example. Maybe something new has changed? But $config->advanced = true; works perfectly and is a better solution as it's already per-template.
  13. Woohoo! Thanks. $config->advanced = true; does the trick!
  14. I found this in the meantime - thanks for this post as well. I got the this working by turning on $config->advanced = true; in config.php which allows hiding the settings tab on a per-template basis! Nice. It seems that the code in the thread turns off the general ProcessWire menus as well: Before and after shots attached. I'm working on 2) now.
  15. Soma, Thank you so much for this. It's a fantastic example which I'm using as of yesterday. I particularly appreciate you posting clean code as I find reading code the best way for me to learn how things work. Do you possibly have any examples of a hook in which I could manipulate more of the admin interface? I'd like to do a couple things: 1. Remove the "settings tab" in the iframe that pops up when editing a PageTable entry. Maybe it's possible to do so with roles and permissions or a technique similar to removing the button. 2. Change the function of the "Add New" button completely - don't create/load the iframe and just create a new PageTable entry programmatically. If there are hooks to point me at I can figure them out. I've spent time with Captain Hook and but am a bit overwhelmed with the sheer number as well as the fact that I don't know much about how the admin interface is constructed.