Jump to content

Flashmaster82

Members
  • Posts

    85
  • Joined

  • Last visited

Recent Profile Visitors

687 profile views

Flashmaster82's Achievements

Sr. Member

Sr. Member (5/6)

12

Reputation

  1. Thanks for the explanation. I wanted to use the eq thing but i don´t know how? Im not that good at PHP but im learning. Did 2 different approaches. $status3 = $pages->get('/bokningsstatus/steg3/'); if ($bookingstatus->booking_status === $status3) { require ('assets/bookingstatus/bookingstatus_step3.inc.php'); } if ($bookingstatus->booking_status->id == 1738) { require ('assets/bookingstatus/bookingstatus_step1.inc.php'); } But i wanted to do an if statement if the status in the dropdown is at the first, second, third etc.. with the eq. Then include the inc file. Because if you change the references i wont work.
  2. I have another page that im using a page reference on (booking_status), i tried with the same logic "eq(1)" but it didnt worked? Is eq only for hooks? if ($bookingstatus->booking_status->eq(1)) { require ('assets/bookingstatus/bookingstatus_step2.inc.php'); } I get "Exception: Method Page::eq does not exist or is not callable in this context"
  3. It worked like a charm. Thank you so much!!! I tried to specify the parent but i didnt worked? $wire->addHookAfter('Pages::added', function(HookEvent $event) { $page = $event->arguments(0); if($page->template != 'booking, parent=/nya-bokningar/') return; $selectable_pages = $page->getInputfield('booking_searchactivator_option')->getSelectablePages($page); $first_selectable_page = $selectable_pages->eq(0); $page->setAndSave('booking_searchactivator_option', $first_selectable_page); });
  4. Thanks so much for the reply 🙂 I will look at this and test it out.
  5. I want to select the first option in a page reference fieldtype when adding a new page (admin). Dont want to target the option id because the value may change. Field = booking_searchactivator_option Template = booking Page reference template = searchactivator My current code is only targeting the page id and not the value. So now it becomes id=1. Also i want to be able to change the value to the second value, third value / position in the dropdown. $wire->addHookAfter('Pages::added', function(HookEvent $event) { $page = $event->arguments(0); if (!$page->matches('template=booking')) return; $aktivator = 1; $page->setAndSave('booking_searchactivator_option', $aktivator); }); i also have another hook that removes already selected page references. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { $page = $event->arguments(0); if($event->object->hasField == 'booking_searchactivator_option') { $pages = $event->wire()->pages; $already_selected_on_another_page = $pages->find("template=searchactivator, booking_searchactivator_option.owner.template=booking, booking_searchactivator_option.owner.id!=$page->id"); $event->return = $event->pages->find("template=searchactivator, sort=sort, id!=$already_selected_on_another_page"); } }); Please help!!
  6. Thank you so much for the solution it worked! This is my current code. $wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) { $page = $event->arguments(0); if($event->object->hasField == 'booking_searchactivator_option') { $pages = $event->wire()->pages; $already_selected_on_another_page = $pages->find("template=searchactivator, booking_searchactivator_option.owner.template=booking, booking_searchactivator_option.owner.id!=$page->id"); $event->return = $event->pages->find("template=searchactivator, id!=$already_selected_on_another_page"); } }); Page reference field: booking_searchactivator_option Template that is referred to in the reference field: searchactivator Template that "booking_searchactivator_option" is used on: booking Selector string in the settings: parent=/sokaktivatorer/, template=searchactivator, sort=name I don´t know what the "owner" does though? If i remove it then it will break? /Thanks
  7. I have a couple of pages that has a specific template. In the template i have a page reference field (Activator). What im trying to achive is when i select an option in the dropdown (Activator) in admin and save, then the specific option is disabled (greyed out) in all of the other pages that has the page reference field (Activator). So basically you can only select one specific option once. But when i unselect the same one i want it to be reset and can be selected again in other pages. Please help!
  8. You can only have Jpg images so try and change and see if it works.
  9. I used this module on my website, but then i unprotected all pages, but in Google results it still says "protected page login etc"? How to fix this?
  10. Is it possible to duplicate/Clone the module so that you have 2 different Forms/Template/Fields/Settings/Admin?
  11. That worked! Yaay. Thanks. I´m only a beginner at php, so it´s not that easy for me 🙂
  12. Well im lost 🙂 This is my current code $page->setAndSave([ 'title' => "($id) $template_label | $address, $ort", 'name' => "$id $template_label $address $ort", 'noHooks' => true ]); and its exactly like in the docs..? https://processwire.com/api/ref/page/set-and-save/
×
×
  • Create New...