Jump to content
Orkun

Complex PHP Selector for pagefield

Recommended Posts

I have a template called "activity" with two pagetable fields.

Fields:

activity_create_cast

activity_create_date

activity_create_cast:

uses "cast" template for creating castpages.

the cast template contains a pagefield called select_multi_dates.

activity_create_date:

uses "date" template for creating datepages.

the date template contains a pagefield called select_activity.

Now what i want is create a cast with activity_create_cast and I want that the selection of the select_multi_dates pagefield should be the pages wich i created before with the activity_create_date.

How can I achieve this under the select_multi_dates pagefield with a PHP-Selector?

I know its complicated PHP-Selector. Hope you can help me.

Thanks for your attention.

Nukro

Share this post


Link to post
Share on other sites

All Castpages are created under the activity:

It looks like this:

post-3125-0-38555900-1444827442_thumb.pn

And the select_multi_dates field is on the cast template. So I thought i could get the current Activity with the casts parent and then access the items/pages from the activity_create_date pagetable.

$currentActivity = $page->parent;

return $currentActivity->activity_create_date;

Unfortunately it doesnt work, I get this error:

Fatal error: Call to a member function has() on a non-object in /Users/praktikant/Sites/Kulturdatenbank.pw.2.0/wire/modules/Inputfield/InputfieldPage/InputfieldPage.module on line 253

Share this post


Link to post
Share on other sites

I tried to echo $page on the select_multi_dates field. I get this:

post-3125-0-96305800-1444828590_thumb.pn

$page dont return the cast page, it returns the "Fredi - edit page process" page.

How can I solve this?

Share this post


Link to post
Share on other sites

The method InputfieldPage::getSelectablePages needs to know the page you are editing. This seems to be wrong and it is probably Fredi's fault since you are getting "his" ID. Try disabling Fredi and see if it works. 

Otherwise you can try to Hook before InputfieldPage::getSelectablePages and make sure it sees the right page

$event->arguments(0, $page_you_want);

I hope this helps. 

Share this post


Link to post
Share on other sites

Thank you for your input Thomas. But it does not matter more because I have changed the concept. I'm working now with Custom Admin Pages in the Backend, creating Dashboards, Listers with ListerPro for the different Pages: Event, Dates, Images, Videos etc.... The Goal is to achieve a Culturedatabase with the Processwire-Backend where you can create/edit events, dates or also import/export the data for individual use in other websites/services. Before I have done this with a Frontend for the Backendsystem where you can create/read/update/delete events, dates with the Fredi-Module from apeisa. But still thank you for your commitment.

PS: Processwire is great :lol:

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 Mithlesh
      Hi there,
      My form is not getting submitted, it is showing:
      Unable to verify successful email delivery of this form submission.
      Attaching for your reference as well: 

      In the Backend, it is showing Connection timed out with smtp.gmail.com
      Pl guide me how to resolve that
    • By CareerTeam GmbH
      Hi there,
      We are an executive search agency based in Germany looking for a freelancer (2-5 days per week) supporting us with the development and design of our websites. The position will be located in Hamburg, Germany and it would be great if you are on short call. German language knowledge is mandatory. 
      You can reach me via email jobs@careerteam.de.
      Thank you!
      Regards
      Annemie
    • By Roberts R
      I have simple page structure:
      category subcategory simple-product simple-product simple-product simple-product subcategory .... category2 so Im at category page and running
      $pages->find("template=simple-product, has_parent=$page, limit=8"); and it returns 0 pages
       
      but this returns 4 pages
      $pages->find("template=simple-product, has_parent=$page"); Can someone explain why limit does not work here?
      EDIT:
      So I did some tests and it seems that any limit=n where n is >= actual page count that is possible ... selector return 0 results.
    • By louisstephens
      I was really unsure of how to actually title this post, so I do apologize (if someone has a better idea, I will gladly edit it). I am using the profields: pagetable field to allow people to create their own "content" (copy, image, button, etc etc) and rearrange it. I also included a field called "column_size" using the RangeSlider set to (1-12).
      I guess I'll clarify a bit more on this. I am using flexbox where the "row" is <section></section> and the columns are <div class="column"></div> have given the "columns"  flex: 1 1 0; so no matter how many columns you have, the columns will automatically adjust for new content. Where my confusion is coming in: If a user has set up 3 copy items (with 12, 5, 7 respectfully for the column_size), how do I actually output this in my template? I was going to use a switch statement to handle the various items which I thought made it quite easy, but with closing sections and columns I have confused myself as I assume I need an if statement to check if the column size is > 12, or = 12 to determine the actual closing/opening of sections. I apologize if I have not made this very clear. I am a bit unsure how to word this let alone to go about this. 
      Im very appreciative of for any insight into this.
       
       
    • By louisstephens
      So I have been hard at work creating url segments for a template (api) and everything is working swimmingly in creating a simple end point for svelte.js. I have however, run into a few questions that I can wrap my head around.
      In my api template I have:
      if($input->urlSegment1 === 'clients') { header('Content-Type: application/json'); $clients = $pages->find("template=clients"); $client_array = array(); foreach ($clients as $client) { $id = $client->id; $title = $client->title; $url = $client->url; $clientName = $client->client_name; $clientColor = $client->client_color->value; $assigned = $client->assigned_to->user_full_name; $client_array[] = array( 'id' => $id, 'code' => $title, 'name' => $clientName, 'associated_users' => $assigned, 'url' => $url ); } $client_json = json_encode($client_array, true); echo $client_json; } The output json from this is:
      [ { "id":1644, "code":"abc", "name":"Test Name", "associated_users":null, "url":"\/pw\/clients\/abc\/" }, { "id": 1645, "code": "xyz", "name": "Test Name", "associated_users": null, "url": "\/pw\/clients\/xyz\/" }, ] I was curious is it possible to add in "clients" before this output json so it would appear as 
      clients: [ { "id":1644, "code":"abc", "name":"Test Name", "associated_users":null, "url":"\/pw\/clients\/abc\/" }, { "id": 1645, "code": "xyz", "name": "Test Name", "associated_users": null, "url": "\/pw\/clients\/xyz\/" }, ] I was not really sure of how to tackle this in my php code, and have spent more time than I care to admit trying to figure it out. Another question I have is that "associated_users" is returning null, which in this instance is correct. It is a multi page field that is set to pull a custom name field from the users template, ie "Louis Stephens" would be associated with the first page. I understand that I need to use a foreach to get the correct data, but I was really unsure of how to place this inside an array, or update the array with the new data. Any help with any of this would greatly be appreciated.
×
×
  • Create New...