gebeer

Page referencefield - custom PHP code not working in repeater

Recommended Posts

Hello,

on a fresh 3.0.62 install I have a page reference field 'mypages' with these settings for selectable pages:

59520a3a3f892_2017-06-27093239.thumb.png.fc7b4fd4029ecb29161e69587a54b494.png

In my site/ready.php I have this hook:

/**
 * custom page select
 */
wire()->addHookAfter('InputfieldPage::getSelectablePages', function($event) {

  if($event->object->name != 'mypages') return;
 
  $pages = new PageArray();
  $pages->add($this->pages->get(1));
  $ids = $pages->explode('id');
  $event->return = $event->pages->getById($ids);

});

On a normal page, the hook is working and the mypages field has only 'Home' in the select dropdown .

But when I put the mypages field inside a repeater, it is not working.

I have this problem on a project that is in development right now and have spent quite some time to try and find the reason. Then I made a fresh PW install to verify the behavior.
No matter if repeater dynamic loading is on or off, the page reference field always returns the  set of pages defined by the settings in the page reference field. The hook is ignored.

Can anyone please verify this and let me know so I can file a bug report. Also if you have an idea how to fix this, I would be happy.

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Cloud8888
      Greetings from germany,

      i develop a shop for a customer and wanted to give them the opportunity to find products without any images so they could easily fill this empty sites.
      The problem is, that this images are placed inside a repeater.
      So the structure for the repeater field is:
      title
      bild (where 1 image can be placed)
      bildrecht (another repeater for placing the copyright  text)

      But here comes my problem.
      I designed a selector that should show me all sites where the repeater count is 0.
      Like :
      template=sorte|artikel,bilderrepeater.count=0
      But it also shows me results, where the repeater count is still 1 or even greater.
      If i save one of these bad results, the selector works fine.

      Is there a way around it ?
      I use pw 3.0.76.

       
    • By cstevensjr

       
      This is the first collaborative project that my wife and myself have worked together on.  The goal was simple --- Create a public online experience that showed off the "Custom Artisan" jewelry that she has made for years.
      https://yellowrosecreations.biz
      The website is built around an e-commerce platform.  Through ongoing work with a new client of mine, I had gotten to know about Ecwid as an e-commerce solution that was tied in closely in with Square (a financial services, merchant services aggregator and mobile payment company).  My work with Ecwid for the past few months afforded me with the opportunity to get this web project up and online in no time.  Let me be clear, while this e-commerce solution works fine, our long term goal is to use Padloper for the online store.  That long term goal is more about controlling where our data resides and being able to freely enhance the total shopping experience.  I already know that a solution based on ProcessWire will give us the ultimate e-commerce flexibility.
      The great thing about the ProcessWire platform is that there are numerous tools that enable you to get things done.  To my delight, I discovered that using the Hanna Code module allowed me to easily integrate Ecwid (which actually means e-commerce widget) code into a ProcessWire website. I will write a separate article about how that works at a later time. 
      The website makes use of the UnSemantic Responsive CSS grid with Zurb Foundation components added/mixed in.  This is an unconventional combination to use, but it works for us.  
      On the ProcessWire side, there were a few critical modules that contributed to gettng this website online:
      TextformatterHannaCode ProcessDatabaseBackups CronjobDatabaseBackup AdminLinksInFrontend ProCache FormBuilder PrevNextTabs WireMailSmtp ImportPagesCSV ProcessEmailToPage MarkupProcesswirePhotoswipe Hanna Code snippets were used throughout to populate the Ecwid Online Shopping Bag, the Ecwid Main Online Store, different Ecwid Product Category Listings, the green Foundation Buttons in the website sidebar and some other webiste features.
      ProcessWire Page Table and Page Reference fields were instrumental in generating the product descriptions that are used on the Ecwid Online Store.  Each jewelry item has it's own page within ProcessWire that can be later used with the Padloper e-commerce solution.

      On the backend side, we were able to create a repository page that keeps track of each product, SKU, pricing and their current disposition status related to the Online Store.

      This has been a fun and fascinating project to work on.  It took us a few weeks to get everything worked out. As I have said before, ProcessWire makes projects of this type possible because you are not limited by the front-end framework you can use.  Even when there are not dedicated modules to incorporate a feature that you like, this platform and it's openness allows you to do things that are impossible to do on other systems.  It just takes a little ingenuity, planning and time on your part to make things work.
       








    • By Albert
      Hy, 
      I cannot get it going. I try to update a repeater field, containing username, email, a int value, a addresse and a description. I post the data to a handlerfile. So far so good. 
      But how can I save the data to the field? 
      The Pages is under home and contains a repeater_field named multi_locations -> this should be updated. 
       
      My try so far: 
      if ($input->post) { // $p = new Page(); // $p->of(false); // $p->parent = $pages->get(1); // $p->template = $pages->get('probleme'); var_dump($p); $melder = $sanitizer->text($input->post->melder); $email = $sanitizer->email($input->post->email); $location = $sanitizer->text($input->post->location); $urgency = $sanitizer->selectorValue($input->post->inlineRadioOptions); $description = $sanitizer->text($input->post->description); echo $melder . "| " . $email . "| " . $location . "| " . $urgency . "| " . $description; $p->multi_locations->title = "tryout"; $p->multi_locations->melder = $melder; $p->multi_locations->mailadresse = $email; $p->multi_locations->map->address = $location; $p->multi_locations->urgency = $urgency; $p->multi_locations->beschreibung = $description; //$p->save();  
      Please help me bring some light into the dark.
       
      Thank you in advance! 
    • By gebeer
      Hello,
      I would like to prevent future editing of a repeater item once a checkbox in the repeater item has been checked. Either the form inputs of the repeater item should be read only or only the field values should be rendered.
      Looking at the module code I can't seem to figure out where to hook for that functionality.
      Any ideas would be much appreciated.
    • By mattcohen
      Hi guys, I'd really appreciate some help from you. I am wondering how I would about using the Selector field type within a repeater.
      It seems kinda bad design to have multiple selectors (e.g. Grid 1, Grid 2, Grid 3) when I could use a repeater for it.
      Using Ryan's example, I have managed to get my repeater to work
      foreach($page->grid_repeater as $grids) { echo "<h2>{$grids->grid_type}</h2><p>"; echo " }