Jump to content
adrian

Batch Child Editor

Recommended Posts

Thanks Adrian, great module!

I'm trying to use it to export users page into csv, but the module doesn't show in "Users" parent page.

Is there a way to make it work?

Glad you like it!

Are you talking about from Access > Users, or Home > Admin > Access > Users ?

The former uses Lister, so I assume you are talking about the latter. If you have ListerPro you can use the export to CSV action from the former. If you don't, then go into the BCE module code and comment out this line:

// don't even consider system templates
if($this->editedPage->template->flags & Template::flagSystem) return;

On the master branch it is line#159 and on dev it is 166.

Let me know if that works for you.

I wouldn't recommend leaving this commented though - I haven't though through it too much, but the Replace mode could cause some major damage pretty quickly :)

Do you need this to be available regularly, or is it a one off need? If you need it regularly I could add any exception for the user page - let me know and we'll work something out.

Share this post


Link to post
Share on other sites

I have bunch of Pages that have

I'm

in their title. BCE doesn't show them correctly, only the "I' is visible under the "TITLE" column. I can add titles correctly and they gets saved (fortunately). I guess it's a bug.

post-3156-0-88262100-1446551581_thumb.pn

Update:

On second save (when title field shows "I" only) the wrong value gets saved.

Share this post


Link to post
Share on other sites

Thanks @adrian

yes i was talking about Home > Admin > Access > Users

Unfortunately i've commented that line, and i can see the Batch Child Editor block in Children Tab, but when i click on export csv nothing happen

And yes i need this to be available regularly to export users.

Thanks for helping.

Share this post


Link to post
Share on other sites

I have bunch of Pages that have

I'm

in their title. BCE doesn't show them correctly, only the "I' is visible under the "TITLE" column. I can add titles correctly and they gets saved (fortunately). I guess it's a bug.

attachicon.gifbce-i-am-bug.png

Update:

On second save (when title field shows "I" only) the wrong value gets saved.

Thanks for reporting @tpr - I have fixed this on the master branch. I have some uncommitted changes to the dev branch at the moment, so the fix won't be on that branch just yet.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks! Just tried and it works fine.

BCE and Migrator saved my *ss today when I needed to migrate 100+ pages, so thanks for these :)

  • Like 1

Share this post


Link to post
Share on other sites

@tpr - glad it works and that Migrator helped to save your *ss too :)
 
 

Thanks @adrian
 
yes i was talking about Home > Admin > Access > Users
 
Unfortunately i've commented that line, and i can see the Batch Child Editor block in Children Tab, but when i click on export csv nothing happen
 
And yes i need this to be available regularly to export users.
 
Thanks for helping.

 
Firstly, I do have a working solution for you, but first a little background :)
 
It is weird that nothing is getting exported - it is definitely exporting a valid CSV file for me. The only problem I am seeing is that I can't control the fields that are exported - it is defaulting to: Set Password, Email Address, Roles
 
The problem is that if you allow the Home > Admin > Access > Users to be separately configurable you should be able to specify the required fields, but the settings don't save, because that page is locked for editing by PW so we are out of luck with that.
 
BUT, here is my working solution, which I think is cleaner than making users navigate to that deep page anyway:

  • Grab the latest master version (there is one critical change to make this work).
  • Create a new page somewhere in the main page tree (not inside the Admin tree) - maybe called "User CSV Export".
  • Make this new page separately configurable in the BCE "Where editing tools are available and separately configurable" settings section.
  • Go to the Settings tab of this new page and configure it to enable Export mode.
  • In the Content / Deletion / Protection section, set the Parent Page to: Home > Admin > Access > Users
  • In the CSV Export Settings, set up the fields to export. You will likely want Name, Email Address, and any custom fields you may have set up.
  • Save settings and then go to where you have BCE displayed (maybe an Inline Fieldset would be a good idea in this case) and click Export.

Works great here, so please test and let me know.

  • Like 2

Share this post


Link to post
Share on other sites

Thanks @adrian .

I'm trying the solution you described. I don't know if I'm doing something wrong but the "Fields to export" select is not showing the user template fields.

I made some screenshot of the setting tab and of the "field to export" select.

The editor is giving me some problem attaching them so here are the links to the screenshots

https://www.dropbox.com/s/16oqik2ann07y40/settings_tab.png?dl=0

https://www.dropbox.com/s/c0h2gvgty27k3uw/Schermata%202015-11-04%20alle%2009.57.46.png?dl=0

Share this post


Link to post
Share on other sites

Ah - sorry - at the moment you will need to check the "User override CSV settings" and then choose the fields to export when going to actually export - does that make sense.

post-985-0-52802100-1446629232_thumb.png

I'll see what I can do about getting the correct fields to also appear in the config settings based on the selected alternate parent page.

Share this post


Link to post
Share on other sites

It seems I have no luck here. I check "Users override CSV settings", then save, but when the page load again "Users override CSV settings" is still unchecked

Share this post


Link to post
Share on other sites

Ok, I just committed a new version (master branch again) that will grab the fields from the selected alternate page (you need to save the page after selecting an alternate parent page to refresh the field list), so you should now be able to set those in  the config settings and not rely on doing it at export. Does this work for you like this?

post-985-0-87894700-1446630925_thumb.png

As for why your override checkbox is not saving, I am completely baffled - do you have debug mode on? Any errors? It looks like all the other settings on that page are saving - correct?

Share this post


Link to post
Share on other sites

Not sure what's about that, but I tried this module and now I get on every page save I see message "Session: Change: status". Took me a while to realize it's BatchChildEditor.

  • Like 1

Share this post


Link to post
Share on other sites

Not sure what's about that, but I tried this module and now I get on every page save I see message "Session: Change: status". Took me a while to realize it's BatchChildEditor.

Thanks for spotting Soma - it seems to come from this code:

            // temporarily put the parent in an unpublished status so that we can check it from
            // the proper context: when page-publish permission exists, a page not not editable
            // if a user doesn't have page-publish permission to it, even though it may still
            // be editable if it was unpublished.
            $parent->addStatus(Page::statusUnpublished);
            $parentEditable = $parent->editable();
            $parent->removeStatus(Page::statusUnpublished);

This is part of a method called getAllowedTemplatesAdd that determines whether the user is allowed to add a template to this parent. It is a modified version of this method: https://github.com/ryancramerdesign/ProcessWire/blob/cffb682836517065d7dd7acf187545a4a80f1769/wire/modules/Process/ProcessPageAdd/ProcessPageAdd.module#L191

I am not sure how to avoid this check. Do you think it is a major concern? I guess it's not ideal that there is a recorded change to a page when saved, even though there are effectively no changes.

Any thoughts?

  • Like 1

Share this post


Link to post
Share on other sites

Why is this needed to change Status and back I don't get it? I don't think it's nice if it's tracked. What if I track changes to my pages? So maybe a trackChange(false) is needed?

Share this post


Link to post
Share on other sites

Just tried a 

$parent->setTrackChanges(false);
$parent->addStatus(Page::statusUnpublished);
$parentEditable = $parent->editable();
$parent->removeStatus(Page::statusUnpublished);
$parent->setTrackChanges(true);
and it wouldn't track it. I think it's something we want to hide from the track change system. What if I'm listening to page changes in my module? :)
 
Edit1: I noticed recently that there's really a lot of such changes going on in PW. Only opening a page editor does change the created_users_id for example. Huh? 
 
Edit2: well I guess it's because I'm tracking every change to page object, so I guess there's maybe some way around it (using page type, template etc, and fields). But still I think such back and forth changing to archive something, those should be hidden from track changing. What you think?
  • Like 1

Share this post


Link to post
Share on other sites

I think that setting TrackChanges to false seems like a great idea - I will happily implement that in BCE - do you want to suggest it to Ryan for the core version of that method?

I noticed recently that there's really a lot of such changes going on in PW. Only opening a page editor does change the created_user_id for example. Huh? 

Just to clarify - this is PW core changes you are talking about and not something caused by BCE - correct?

Share this post


Link to post
Share on other sites

I would suggest it to Ryan see what he thinks.

Sorry, no this is core and not BCE.

  • Like 1

Share this post


Link to post
Share on other sites

I would suggest it to Ryan see what he thinks.

Sorry, no this is core and not BCE.

Great - just committed a new version of BCE (master branch) with those changes - thanks for figuring this out!

  • Like 1

Share this post


Link to post
Share on other sites

Ehrm I'm not sure it's really correct code. :) Just trying to get my head around it. $page->setTrackChanges(false) isn't correct but it may have an effect to clear out changes? Sorry for the confusion.


Lol I'm so stupid, looking at the wrong method in Wire.php, no it's ok I guess. :) Sorry again.

Share this post


Link to post
Share on other sites

Lol I'm so stupid, looking at the wrong method in Wire.php, no it's ok I guess. :) Sorry again.

No problem - it looks like that approach of setting to false, doing something, and then setting to true is used in several places in the PW core. Interestingly, the cheatsheet mentions setting to false, but doesn't show true as an option - maybe just meant to be assumed - weird it doesn't show:

$a->setTrackChanges(true|false)

That would be consistent with others.

Share this post


Link to post
Share on other sites

I was about to change it on cheatsheet. But now it's because it's only a set and default is ON. Hence there's two entries in cheatsheet and not (true|false).


So a 

$parent->setTrackChanges(false);

...

$parent->setTrackChanges();

would be sufficient.

  • Like 1

Share this post


Link to post
Share on other sites

Just wanted to let you guys know that I have committed some changes over the last couple of days that brings complete live updating of child page details (name, template, hidden status, unpublished status, and removal of a row if deleted) in the edit mode table after making edits to a specific page in a modal popup.

It might not seem like much, but it makes this mode much more functional and intuitive.

Please let me know if you notice any problems.

  • Like 4

Share this post


Link to post
Share on other sites

Are admin pages disabled by default? I have a few pages under the Admin branch (form submissions) and BCE doesn't seem to be present there. Is there a way to allow it there?

(using devns 3.0.5)

Share this post


Link to post
Share on other sites

Are admin pages disabled by default? I have a few pages under the Admin branch (form submissions) and BCE doesn't seem to be present there. Is there a way to allow it there?

(using devns 3.0.5)

Yes they are disabled by default, but I just added a new option under Content / Deletion / Protection to enable BCE editing of the Admin page branch.

Obviously this has the potential to completely break a PW install so use carefully at your own risk :)

Share this post


Link to post
Share on other sites

Hi Adrian!

When I mark children page for delete and then Save the page, I get errors (see attachment). The page itself (http://localhost/processwire/page/edit/?id=1) returns " The process returned no content." Could it be my fault (playing around...)? No problem with editing and adding pages.

Thanks for the report and sorry about that - looks like I introduced a bug in my commits from yesterday. Should be fixed now in the latest version. Please let me know if you still have any problems.

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 Gadgetto
      SnipWire - Snipcart integration for ProcessWire
      Snipcart is a powerful 3rd party, developer-first HTML/JavaScript shopping cart platform. SnipWire is the missing link between Snipcart and the content management framework ProcessWire.
      With SnipWire, you can quickly turn any ProcessWire site into a Snipcart online shop. The SnipWire plugin helps you to get your store up and running in no time. Detailed knowledge of the Snipcart system is not required.
      SnipWire is free and open source licensed under Mozilla Public License 2.0! A lot of work and effort has gone into development. It would be nice if you could donate an amount to support further development:

      Status update links (inside this thread) for SnipWire development
      2020-07-03 -- SnipWire 0.8.7 (beta) released! Fixes some small bugs and adds an indicator for TEST mode 2020-04-06 -- SnipWire 0.8.6 (beta) released! Adds support for Snipcart subscriptions and also fixes some problems 2020-03-21 -- SnipWire 0.8.5 (beta) released! Improves SnipWires webhooks interface and provides some other fixes and additions 2020-03-03 -- SnipWire 0.8.4 (beta) released! Improves compatibility for Windows based Systems. 2020-03-01 -- SnipWire 0.8.3 (beta) released! The installation and uninstallation process has been heavily revised. 2020-02-08 -- SnipWire 0.8.2 (beta) released! Added a feature to change the cart and catalogue currency by GET, POST or SESSION param 2020-02-03 -- SnipWire 0.8.1 (beta) released! All custom classes moved into their own namespaces. 2020-02-01 -- SnipWire is now available via ProcessWire's module directory! 2020-01-30 -- SnipWire 0.8.0 (beta) first public release! (module just submitted to the PW modules directory) 2020-01-28 -- added Custom Order Fields feature (first SnipWire release version is near!) 2020-01-21 -- Snipcart v3 - when will the new cart system be implemented? 2020-01-19 -- integrated taxes provider finished (+ very flexible shipping taxes handling) 2020-01-14 -- new date range picker, discount editor, order notifiactions, order statuses, and more ... 2019-11-15 -- orders filter, order details, download + resend invoices, refunds 2019-10-18 -- list filters, REST API improvements, new docs platform, and more ... 2019-08-08 -- dashboard interface, currency selector, managing Orders, Customers and Products, Added a WireTabs, refinded caching behavior 2019-06-15 -- taxes provider, shop templates update, multiCURL implementation, and more ... 2019-06-02 -- FieldtypeSnipWireTaxSelector 2019-05-25 -- SnipWire will be free and open source Plugin Key Features
      Fast and simple store setup Full integration of the Snipcart dashboard into the ProcessWire backend (no need to leave the ProcessWire admin area) Browse and manage orders, customers, discounts, abandoned carts, and more Multi currency support Custom order and cart fields Process refunds and send customer notifications from within the ProcessWire backend Process Abandoned Carts + sending messages to customers from within the ProcessWire backend Complete Snipcart webhooks integration (all events are hookable via ProcessWire hooks) Integrated taxes provider (which is more flexible then Snipcart own provider) Useful Links
      SnipWire in PW modules directory SnipWire Docs (please note that the documentation is a work in progress) SnipWire @GitHub (feature requests and suggestions for improvement are welcome - I also accept pull requests) Snipcart Website  

       
      ---- INITIAL POST FROM 2019-05-25 ----
       
    • By Sten
      Hello
      Till now I hacked something with the twig template but it works no more with new PW versions so I look forward to create a module. I am working on a site in multiple languages : French, English, Italian, German, Spanish, Portuguese, Hebrew, Russian. The new posts are entered in any language with a field for language. Till now, I got twig files to get the translations with constants defined for each part of the pages.
      So I'd like to create a module to include theses files added according to the url /fr/en/...
      Have you some observations to do before I begin about the direction to take ?
      Thank you
    • By ukyo
      Mystique Module for ProcessWire CMS/CMF
      Github repo : https://github.com/trk/Mystique
      Mystique module allow you to create dynamic fields and store dynamic fields data on database by using a config file.
      Requirements
      ProcessWire 3.0 or newer PHP 7.0 or newer FieldtypeMystique InputfieldMystique Installation
      Install the module from the modules directory:
      Via Composer:
      composer require trk/mystique Via git clone:
      cd your-processwire-project-folder/ cd site/modules/ git clone https://github.com/trk/Mystique.git Module in live reaction with your Mystique config file
      This mean if you remove a field from your config file, field will be removed from edit screen. As you see on youtube video.
      Using Mystique with your module or use different configs path, autoload need to be true for modules
      Default configs path is site/templates/configs/, and your config file name need to start with Mystique. and need to end with .php extension.
      Adding custom path not supporting anymore !
      // Add your custom path inside your module class`init` function, didn't tested outside public function init() { $path = __DIR__ . DIRECTORY_SEPARATOR . 'configs' . DIRECTORY_SEPARATOR; Mystique::add($path); } Mystique module will search site/modules/**/configs/Mystique.*.php and site/templates/Mystique.*.php paths for Mystique config files.
      All config files need to return a PHP ARRAY like examples.
      Usage almost same with ProcessWire Inputfield Api, only difference is set and showIf usage like on example.
      <?php namespace ProcessWire; /** * Resource : testing-mystique */ return [ 'title' => __('Testing Mystique'), 'fields' => [ 'text_field' => [ 'label' => __('You can use short named types'), 'description' => __('In file showIf working like example'), 'notes' => __('Also you can use $input->set() method'), 'type' => 'text', 'showIf' => [ 'another_text' => "=''" ], 'set' => [ 'showCount' => InputfieldText::showCountChars, 'maxlength' => 255 ], 'attr' => [ 'attr-foo' => 'bar', 'attr-bar' => 'foo' ] ], 'another_text' => [ 'label' => __('Another text field (default type is text)') ] ] ]; Example:
      site/templates/configs/Mystique.seo-fields.php <?php namespace ProcessWire; /** * Resource : seo-fields */ return [ 'title' => __('Seo fields'), 'fields' => [ 'window_title' => [ 'label' => __('Window title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'attr' => [ 'placeholder' => __('Enter a window title') ] ], 'navigation_title' => [ 'label' => __('Navigation title'), 'type' => Mystique::TEXT, // or InputfieldText 'useLanguages' => true, 'showIf' => [ 'window_title' => "!=''" ], 'attr' => [ 'placeholder' => __('Enter a navigation title') ] ], 'description' => [ 'label' => __('Description for search engines'), 'type' => Mystique::TEXTAREA, 'useLanguages' => true ], 'page_tpye' => [ 'label' => __('Type'), 'type' => Mystique::SELECT, 'options' => [ 'basic' => __('Basic page'), 'gallery' => __('Gallery'), 'blog' => __('Blog') ] ], 'show_on_nav' => [ 'label' => __('Display this page on navigation'), 'type' => Mystique::CHECKBOX ] ] ]; Searching data on Mystique field is limited. Because, Mystique saving data to database in json format. When you make search for Mystique field, operator not important. Operator will be changed with %= operator.
      Search example
      $navigationPages = pages()->find('my_mystique_field.show_on_nav=1'); $navigationPages = pages()->find('my_mystique_field.page_tpye=gallery');
    • By Robin S
      This is a module I made as an experiment a while ago and never got around to releasing publicly. At the time it was prompted by discussions around using Repeater fields for "page builder" purposes, where the depth feature could possibly be used for elements that would be nested inside other elements. I thought it would be useful to enforce some depth rules and translate the depth data into a multi-dimensional array structure.
      I'm not using this module anywhere myself but maybe it's useful to somebody.
      Repeater Depth Helper
      This module does two things relating to Repeater fields that have the "Item depth" option enabled:
      It enforces some depth rules for Repeater fields on save. Those rules are:
      The first item must have a depth of zero. Each item depth must not be more than one greater than previous item depth. It provides a RepeaterPageArray::getDepthStructure helper method that returns a nested depth structure for a Repeater field value.
      Helper method
      The module adds a RepeaterPageArray::getDepthStructure method that returns a multi-dimensional array where the key is the page ID and the value is an array of nested "child" items, or null if there are no nested children.
      Example

      The module doesn't make any assumptions about how you might want to use the depth structure array, but here is a way you might use it to output a nested unordered list.
      // Output a nested unordered list from a depth structure array function outputNestedList($depth_structure, $repeater_items) { $out = "<ul>"; foreach($depth_structure as $page_id => $nested_children) { $out .= "<li>" . $repeater_items->get("id=$page_id")->title; // Go recursive if there are nested children if(is_array($nested_children)) $out .= outputNestedList($nested_children, $repeater_items); $out .= "</li>"; } $out .= "</ul>"; return $out; } $repeater_items = $page->my_repeater; $depth_structure = $repeater_items->getDepthStructure(); echo outputNestedList($depth_structure, $repeater_items);
       
      https://github.com/Toutouwai/RepeaterDepthHelper
      https://modules.processwire.com/modules/repeater-depth-helper/
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
×
×
  • Create New...