Jump to content

Mackski

Members
  • Posts

    140
  • Joined

  • Last visited

Everything posted by Mackski

  1. I've managed to modified the original module to include a InputfieldPageListSelect. Probably not good for large amounts of images due to the ajax calls. However for my purposes, a hero slider to link items, it works fine. In template: <a href="<?php echo $pages->get($img->link)->url?>"> FieldtypeImageExtra-PageListSelect.zip
  2. Was a solution found for this? I require pages to be assoicated with images also.
  3. Thanks Joss, This does make sense, and you are right, a single allowed child template shows the title alias.
  4. Something small one of my clients bought to my attention: I know once you save your template, that you can set alias's for your page fields, such as title, headline etc. However when you create a new page, it does not display this alias, not until you've created, then begin editing. It would be great to show this alias at the time of creation, it would lessen confustion. The use case, is sometimes you might be creating page where the word "Title" can be miss-leading. or "Title" is offered as a different field on the template. I'm just being picky, perhaps I get my hands dirty with a module to do this.
  5. I've added an extra field, which is just a text field for linking to other pages. The user has to copy and paste this link manually, it would be much better to use a pageList select. Any pointers on how I can achive this?
  6. The page is a book form, it has a number of repeaters for products. I'm just totalling them, and applying some calculations, ie: delivery costs, discounts etc. and displaying the order total in a dummy field for user reference. As stated, I could use Page::saveReady, but it means I have to re-save all existing pages. This way, I can just calculate it on-the-fly, as it's something the user does not modify directly.
  7. Thanks Soma, That's fixed it. Could there be a better hook point, ie: Page::loaded ? for these type of operations?
  8. It doesn't seem to work, here are the hook methods I've tried: $this->addHookBefore('ProcessPageEdit::buildForm', $this, 'totalBooking'); $this->addHookAfter('ProcessPageEdit::buildForm', $this, 'totalBooking'); $this->addHook('ProcessPageEdit::buildForm', $this, 'totalBooking'); I can save the field like this: $this->addHookBefore('Pages::saveReady', $this, 'totalBooking'); But I don't want to re-save a few hundred pages, just have it calculate dyanmically at page load.
  9. This might seem a trivial question to you long time PW users, I'm still getting my head around things. I need to add a hook, after values have been populated to do some calcuations from selected fields. I'm struggling to work out exactly where to add my hook. Is there a detailed breakdown of the order of method execution in PW, in relation to loading a page? My code is as follows: $this->addHook('ProcessPageEdit::buildForm', $this, 'totalBooking'); // calculate and show the total booking amount in a given field public function totalBooking(HookEvent $event) { $total = 0; $page = $event->arguments('page'); if($page->template != "booking") return; $total = $page->booking_delivery_cost; if(count($page->booking_items) > 1 ) { foreach($page->booking_items as $item) { $total += ($item->booking_item_cost * $item->booking_qty); } } if($page->booking_discount > 0) { $total -= $page->booking_discount; } $page->booking_total_amount = $total; return; }
  10. Thanks Ryan, I ended up hooking into ProcessPageEdit::buildForm: $this->addHook('ProcessPageEdit::buildForm', $this, 'addButton'); public function addButton(HookEvent $event) { $href = $this->config->urls->admin.'page/edit/?id='.$this->input->get->id.'&e=1'; $field = $this->modules->get('InputfieldButton'); $field->attr('id+name', 'email_customer'); $field->attr('class', $field->class); $field->attr('value', 'Email Booking To Customer'); $field->attr('href',$href); $event->return = $event->return->append($field); } I then just check for $_GET['e'], and undertake the workflow needed, and redirect back to the original edit page. A bit of a circus, but gets the job done. Is there a better way to utilize hooks for custom workflows like this?
  11. I have the exact same code on two pages, however I get this error when the bootstrapped page tries to create the repeaters for a page. Error: Uncaught exception 'WireException' with message 'Can't save page 0: /1385807809-24-1/: It has no parent assigned' Here is the code in the loop used on both pages to create the repeaters: $item = $p->booking_items->getNew(); $item->booking_item = $id; // calculate total item cost, based on postcode $item->booking_item_cost = $row['item'.$x.'cost']; // always just 1 for checkbox items $item->booking_qty = $qty; Is this a possible bug with boostrapping? I'm stumped as to why it's not working when strapped. [Edit] Looks like there was an issue with repeaters in the trash, after I emptied the trash the script worked.
  12. Hi Guys, I'm trying to add an additional button when editing a page in admin. "Save and email". The idea is to save the form, then email it's contents using a template to the supplied email address, such as a booking confirmation, or order confirmation. I've been able to hook and create the button, however I cant seem to work out how to progmatically save the form. As far as I can tell, the button submit's the form but $input->post is empty.
  13. I think with the module you mention, you can save a default action after saving a page. Perhaps my module is more usefull in this senario as an alternate action like "Save and Restore Page List". For now, my client is happy with the solution at hand, they mainly add news and blog items, multiples at a time in the same place, so it makes sense.
  14. I agree with Soma here, most clients and users in general, will be annoyed at not seeing the previoiusly opened state in the page tree. I decided to write my first module to solve this. https://github.com/mackski/processwire-PageTreeState Ryan, let me that this opportunity to congratulate you on an excellent piece of software. I also wanted this to work with Somas Fancy Admin Module, I added the following to initFancyBox in FancyAdminMode.js, line 53: callbackOnClose: function () { parent.location.reload(true); }
×
×
  • Create New...