Jump to content

Add existing pages to pageTable


uliverse
 Share

Recommended Posts

I had this issue yesterday - client says they added something to a page table, and then it disappeared. In this case we are not adding as children, but have set a parent.

My suspicion is that the client had multiple tabs open, and saved the record later on another tab where they didn't have the item added.
This then creates the orphaned page.

so, same code as adrian posted, i'm using basically to fix these orphans...

$p = $pages->get(####);
$p->of(false);
$p->page_table->add($pages->get(####));
$p->save('page_table');

though i think it will probably be better at some point for me to save the value of the page that created the record into that page table item, and then have a hook that runs and checks for orphans (not children) and adds those to the table.

Link to comment
Share on other sites

1 hour ago, uliverse said:

Thanks for the ideas. I need to be able to do that in the backend. But it seems there is no simple way of doing that...

The code in that link I posted hooks into the rendering of the page table field in the backend and automatically adds existing child pages. Is that not what you are looking to do?

Link to comment
Share on other sites

3 minutes ago, adrian said:

The code in that link I posted hooks into the rendering of the page table field in the backend and automatically adds existing child pages. Is that not what you are looking to do?

Yes and no... it's a bit more complicated I guess... I need to be able to do this manually. If there is no simple solution, I will find a workaround. Thanks for your help, though!

Link to comment
Share on other sites

Just now, uliverse said:

Yes and no... it's a bit more complicated I guess... I need to be able to do this manually. If there is no simple solution, I will find a workaround. Thanks for your help, though!

You could make use of http://modules.processwire.com/modules/process-admin-actions/ and build a custom action that lets you choose a Page Table field and then a page to add to that field.

Or you could use http://modules.processwire.com/modules/fieldtype-runtime-markup/ and build a page selector field just above or below the Page Table field and on pag save, process the selected page and add it to the PT field.

You could also hook into InputfieldPageTable::render and add the page selector interface there.

Lots of options really ?

  • Like 1
Link to comment
Share on other sites

1 minute ago, adrian said:

You could make use of http://modules.processwire.com/modules/process-admin-actions/ and build a custom action that lets you choose a Page Table field and then a page to add to that field.

Or you could use http://modules.processwire.com/modules/fieldtype-runtime-markup/ and build a page selector field just above or below the Page Table field and on pag save, process the selected page and add it to the PT field.

You could also hook into InputfieldPageTable::render and add the page selector interface there.

Lots of options really ?

Hmmm... I will look into those options! Thanks a lot! You are always very helpful.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...