Jump to content

Page Add Comfort Option


kixe
 Share

Recommended Posts

I was looking for a more comfortable solution to add pages from a PageField Select. I ended up in this small module. Which is quite simple, but very useful. I created a PageField and another field of Type AddPage (requires FieldtypePageTable) with same settings for template and parent. Now I can easily add the page in the Modal.

If you need it, take it as a Christmas Present from my side. :) (no christmas smiley available ... )
Dear Ryan, dear community, I wish you all the best for christmas and the upcoming year.
 

<?php

/**
 * Excellent side dish to Fieldtype Page. Doesn't store any data. Provides comfortable page creation.
 *
 * made by kixe (Christoph Thelen) 22.12.15
 * Licensed under GNU/GPL v3
 *
 * ProcessWire 2.x
 * Copyright (C) 2015 by Ryan Cramer
 * Licensed under GNU/GPL v2, see LICENSE.TXT
 *
 * http://processwire.com
 *
 *
 */

class FieldtypeAddPage extends FieldtypePageTable implements Module {

    public static function getModuleInfo() {
        return array(
            'title' => 'Fieldtype Add Page',
            'version' => 100,
            'summary' => 'Excellent side dish to Fieldtype Page. Doesn\'t store any data. Provides comfortable page creation.',
            'author' => 'kixe',
            'requires' => 'FieldtypePageTable'
            );
    }

    public function init() {
        // prevent data storage
        $this->addHookAfter('FieldtypePageTable::sleepValue', function($event) {        
            $event->return = array();
        });
        // unneeded configuration fields can be removed
        $this->addHookAfter('FieldtypePageTable::getConfigInputfields', function($event) {
               $inputfields = $event->return;
            $page_behavior = $inputfields->children()->get(2);        
            $removes = array('sortfields','trashOnDelete','unpubOnTrash','unpubOnUnpub',$page_behavior);
            foreach ($removes as $remove) $inputfields->remove($remove);
            $event->return = $inputfields;
        });
    }
}

Screencast
post-1246-0-80972100-1451889234_thumb.gi

  • Like 12
Link to comment
Share on other sites

hey kixe,

also the best wishes to you :) would you mind doing a short screencast so that we do not have to install it, create the fields etc...

http://www.cockos.com/licecap/ is a cool small tool to do that in seconds on win/osx. it creates a GIF so you don't even have to upload it to youtube or the like. just record and post it directly here in the forum.

thank you for sharing your module :)

  • Like 13
Link to comment
Share on other sites

  • 2 weeks later...

Looks great but, could you run a pagereload on saving the modal via JS? So the option is already there.

Users are most not very familiar with browser reloading (having a actual problem with some UI things that users don't get with pagetables...and modals...and saving ;)

Very good improvment so far!

Best regards mr-fan

  • Like 1
Link to comment
Share on other sites

What's about not yet saved content in other fields when reloading? Will this get saved first? Also, is it good to save (optionally massive) changes without the knowing of the user? At least, I think it only could be an option, not the default.

  • Like 1
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

×
×
  • Create New...