Jump to content

pagefield selectable pages "custom find" or?

Recommended Posts

This issue is related to the backend only, not frontend templates.

I have a pagefield called "programs_list" that displays a list of "programs" and this works fine however the ID's assigned to those items are "PW" page id's.

How can I match a selected item to a custom field value instead of the default PW ID ?

I've imported a large volume of data using the API and this data has a field called "program_id" that I need to match with the "programs_list" pagefield.

The "programs_list" pagefield uses a template that contains a "legacy_id" field that I need to match up with the imported datas "program_id" so that it shows the correct item as being selected.

Any examples on how to go about achieving the desired result would be much appreciated.

thanks in advance



Share this post

Link to post
Share on other sites

Hi, If I understand you right, you need to hook into getSelectablePages. I presume you use ASM select, so one example can be found here:


Also, you can perform a google search like : https://www.google.hu/search?q="getSelectablePages"+site%3Aprocesswire.com%2Ftalk


Edited by szabesz
link's href fix

Share this post

Link to post
Share on other sites

I thin what you are looking for is the "Custom PHP code" in the Input tab of the field cnfiguration screen for your programs_list field


In my case the field name is "myplaces"

Now Go and insert this hook into site/ready.php

$wire->addHookAfter('InputfieldPage::getSelectablePages', function($event) {
  if($event->object->hasField == 'programs_list') {
    $page = $event->arguments('page');
    $event->return = $event->pages->find("template=yourTemplateForProgramPages, program_id={$page->legacy_id});

This gets the legazy_id of the page that you are currently editing and then finds all program pages with that id in field program_id.

  • Like 3

Share this post

Link to post
Share on other sites

@szabesz @gebeer   hi thank you both

I am looking at how to do this only in the Admin CMS, is it possible?

it seems the code you shared is for frontend, can it be done for admin cms ?


Share this post

Link to post
Share on other sites
4 minutes ago, neosin said:

Admin CMS

Yeah, we got that ;) Since inputfields are used by the admin, hooking into InputfieldPage::getSelectablePages is what makes ASM selects (and other multi page inputfields) "customizable".

  • Like 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...