Jump to content
adrian

Batch Child Editor

Recommended Posts

Pleased to say I found the solution to my problem - in the end it wasn't an issue with this module, it was some other code that I had on my site which was echoing to the output stream.  I have now removed that errant code and all is now fine.

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi,

My page template contains fields of type pagefield (among other fields).
When adding or updating pages, I use blank values for these page fields.
The CSV looks something like this:

title,contentTextarea,filterA,filterB
First page title,"<p>Text</p>",,
Second page title,"<p>Text</p>",,

Now BCE/PW generates a new page as a child of the page that is defined as the parent of the pages that are selectable through the page field. Or simpler: adding/updating results in one new filter inside of both filter groups. The new pages have an empty title field.

What value do I have to enter for the page fields in the csv to not select a page (filter) and to not generate new pages (filters)?

  • Like 1

Share this post


Link to post
Share on other sites

I'm working on a setup with no title fields. It was quite easy to edit "Import Pages From CSV" module to accept import data without titles. However, the module messes up the data->field pairings when using Tab separated data (I will report it later).

I would like to try Batch Child Editor to import my data, but it is not as obvious how to tweak it so titles are not required. I mean how to deal with the page naming after commenting out the if(!in_array('title' block starting from line 249. Page names as IDs would be fine, but what is the most straightforward way to achieve it?

Thanks.

Edit: urgh.. apparently I was wrong with "Import Pages From CSV" messing up the field pairings. I don't understand why I cannot reproduce the problem anymore. The only thing I can think of is I was in somehow dyslexic mode when staring at the data.

Share this post


Link to post
Share on other sites

@Beluga - it sounds like you sorted out your problem with the Import Pages From CSV module, but if you decide to come back to BCE let me know and I'll see what I can do about adding support for no title pages.

Share this post


Link to post
Share on other sites

Thanks :) I am using BCE anyways, even though not for this particular corner case.

One thing that would be interesting to hear is performance on import of large amounts of CSV data compared with Ryan's module. I am getting massive execution times on a local environment, hours, for a set with 16 columns and 35k rows (I have not yet done a successful import). I looked at these types of answers: http://stackoverflow.com/a/3908669 and tuned my MySQL settings, but I guess PW's page creation strategy should match..

Share this post


Link to post
Share on other sites

@Beluga - are those massive execution times with BCE or Ryan's module? I am using a third party csv parser - I don't think its approach is very efficient, but php's built-in parser is crap when it comes to certain situations. There might be better options out there though. BCE doesn't make any SQL queries directly so not sure any of those mentioned tweaks would be any use. Also given that in PW each field has its own table I don't know how you could make use of LOAD DATA INFILE etc because you'd have to do a lot of data manipulation before inserting so that you were populating one table at a time with all required data - sounds like a real likelyhood of introducing data integrity problems. That said, if you find something that makes a dramatic difference, please let us know.

Share this post


Link to post
Share on other sites

It is in Ryan's module. I guess I could later share the file (+ exported PW fields) for testing as the data will be completely public anyways (and even is now in an older site).

Share this post


Link to post
Share on other sites

@adrian

On a multilanguage site, loading the Children tab (BCE) shows the titles for the default language if there are no title set for the current language which is fine. But if I save the page, even without any editing, these default titles are saved to the DB (for the non-default language). This happens only after navigating to the Children tab.

From a user/editor POV I regard this as a bug, do you think there's an easy fix? So do not overwrite empty titles with the titles from the default language.

Currently it's not an issue because all titles will be translated for all languages but it's a bit confusing imo.

  • Like 1

Share this post


Link to post
Share on other sites

Hey @tpr - good catch. I am looking into this now and actually thinking about revisiting the fairly recent change we discussed that shows the default language title when there is no title for the current user language. I am thinking about leaving the title field empty and maybe putting the default language in the tooltip of the warning icon that shows up. I also need to revisit how page names are handled - at the moment it's a mess if you change the title because it changes the name for all languages.

Anyway, let me know what you think about my idea for making the title blank if it's blank for the user's language - just want to make sure I am not making it worse for anyone.

Share this post


Link to post
Share on other sites

I guess blanks would be better if that would prevent unintended saves, thanks. Hiding them in a tooltip is perhaps not the best idea, it would be better to make them visible all the time (wouldn't require hovering with the mouse).

22 minutes ago, adrian said:

at the moment it's a mess if you change the title because it changes the name for all languages.

Actually I could add non-default language titles and other titles were remained intact. But I have the Page Rename Options plugin installed, maybe that's interfering.

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, tpr said:

I guess blanks would be better if that would prevent unintended saves, thanks. Hiding them in a tooltip is perhaps not the best idea, it would be better to make them visible all the time (wouldn't require hovering with the mouse).

Well it's easy enough to not have them save to other languages even if the default is populated, but I think populating them is a little confusing still. What about setting the html5 placeholder as the default language title. Do you think that would be a reasonable UX?

Share this post


Link to post
Share on other sites

Haha, that was my first idea when reading the intro of your post :) I would say yes, and that would allow seeing the default title when clearing the field (if you add the placeholder to all title fields, not only to empty's)

  • Like 1

Share this post


Link to post
Share on other sites

Hey @tpr - I have made an initial (although took much longer than I thought) start on support multi-language in Edit mode. Keep in mind that this is not designed to make it possible to edit all languages at once, but rather add proper support for editing the title and name for the user's current language.

Here you can see the same set of child pages in Portuguese and then the default English.

The keys things are:

  • When viewing a non-default language the Title and Name columns have the current language in parentheses.
  • Title is left blank for the current language if no language-specific version is available (uses "Placeholder" to show default language title).
  • Name is left blank for the current language if no language-specific version is available.
  • If you have the BCE "Overwrite Names" setting checked, the name for the current language will be created/updated to match the entered title.
  • If you edit the page in a modal and save, the title and name for the current language will populate the edit mode interface instantly when modal is closed.
  • Unrelated to multi-language, but there is now a new "edit in normal mode" icon - sometimes I prefer this to modal and think a link from here is nice.

I am going to attach the new version here for the moment - please let me know if everything works as expected for you.

 

Portuguese

58b0bf2952fc6_ScreenShot2017-02-24at3_17_33PM.thumb.png.57365f3bcbc9e0fcdf441823da4d099c.png

 

Default: English

58b0bba87beb1_ScreenShot2017-02-24at3_02_49PM.thumb.png.135dfb6d5cec356fb94dbf20c6396e78.png

 

BatchChildEditor.zip

  • Like 2

Share this post


Link to post
Share on other sites

Thanks - all seem to work fine here.

I feel the empty "name" column for non-default language is a bit misleading, perhaps adding the default name there in grey would be less confusing? Now it looks like there's no name provided (which can't be as it's required). Plus this way you don't know the page name.

The new edit mode for me is not very helpful because I can open the modal link in a new tab with middle-click. But of course it can be handy for others.

Btw, what about displaying the "Active" state of pages in multilanguage installs?

  • Like 1

Share this post


Link to post
Share on other sites
6 hours ago, tpr said:

I feel the empty "name" column for non-default language is a bit misleading, perhaps adding the default name there in grey would be less confusing?

I agree, but I use grey to indicate a hidden page (and strikethrough for unpublished). I know they aren't essential because of the hidden and unpublished checkbox columns, but it's still a nice familiar visual indicator. Any thoughts?

6 hours ago, tpr said:

The new edit mode for me is not very helpful because I can open the modal link in a new tab with middle-

I don't know how given that the modal edit icon has no link, but rather a data-url attribute. Are you sure this works for you?

6 hours ago, tpr said:

Btw, what about displaying the "Active" state of pages in multilanguage installs?

Seems like a great idea - thanks!

Share this post


Link to post
Share on other sites

Middle-click to open link: sorry, it was the same page that opened, not the one in the list. What if it had a link too, would the modal stop functioning?

Empty "name" for non-default language names: perhaps using square brackets, or something similar, eg "*pagename"?

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, tpr said:

Middle-click to open link: sorry, it was the same page that opened, not the one in the list. What if it had a link too, would the modal stop functioning?

Adding a link as well makes it possible to middle click / right click and open in new tab, so I have removed the additional link

4 hours ago, tpr said:

Empty "name" for non-default language names: perhaps using square brackets, or something similar, eg "*pagename"?

I went with another warning icon which I think works fine.

10 hours ago, tpr said:

Btw, what about displaying the "Active" state of pages in multilanguage installs?

Available in the new version.

58b1d1b0c137c_ScreenShot2017-02-25at10_47_05AM.thumb.png.28494c142424017f6253662e6cce5ddb.png

The one remaining issue (that I know of) with the attached version is how to handle newly added pages (with Add New) when they are added by a user when a non-default language is selected. The problem is that the default title is not populated and the default name is automatically populated with a timestamp. The easy option would be to disable adding new pages from non-default languages, but I think I should probably populate the default name with the same name as the language used to add the page. As for the title, maybe showing nothing for the default title is ok?

What do you think - is adding new pages from the non-default language something that should be allowed?

This is what it looks like after adding the Test page when in Portuguese and then switching to default (English):

58b1d7e580914_ScreenShot2017-02-25at11_14_54AM.thumb.png.4e76739d9d3bc5cb0fa8aeb89fc53782.png

BatchChildEditor.zip

Share this post


Link to post
Share on other sites

What about the usefulness of having an "active" checkbox column for each available language?

Share this post


Link to post
Share on other sites

Thanks, much better :) Perhaps I would change the new exclamation icon to "fa-info-circle" because it's less strict. Sometimes the page name is intentionally the same in all languages so it's not necessarily an error (eg. /sport/). But the same holds true for the "title" field too.

I like the active checkboxes. Or do you mean displaying checkboxes for all languages? How? Perhaps displaying a list of languages + active state in a tooltip on hover? That would be a handy extra info so one could edit the page in question if needed.

As for the add new page for non-default language, it's a tough one, I would say leave it as it is and improve later :)

  • Like 1

Share this post


Link to post
Share on other sites

Thanks again @tpr for the feedback. I have changed the icon to the info-circle.

I have added a new tooltip which provides a summary of titles/names for all languages:

58b49a9abb979_ScreenShot2017-02-27at1_29_43PM.png.ca48416fd60447639b96e2ec528bbb99.png

 

For the Add New page problem - I decided to go with populating the default language with the values for the current user language so there is at least valid entries for these that can be edited later if needed.

Note that I also added a Language label at the top of the table (rather than being added to several columns in the table). 

I would also like to mention the awesome Language Switcher in your AOS module - I think that having that enabled along with the new changes to BCE actually makes for a pretty decent start to multi-language support because it makes it so easy to instantly switch languages.

I think this new version is ready for release, but will attach here for one more review by you (and anyone else who is interested).

Thanks,
Adrian

 

BatchChildEditor.zip

  • Like 2

Share this post


Link to post
Share on other sites

Great updates, thanks! My only concern is the styling (again :)) of the new tooltip. It's too big here and all uppercase, I guess some CSS is interfering. 

My only idea that could work is adding a +/- icons to the end of the rows (or start), and clicking on them would open a full-width row below the actual line containing all these details. Of course this would require a click to work (and another to close) but maybe it would worth it. But it's just an idea.

bce-tooltip.png

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, tpr said:

My only idea that could work is adding a +/- icons to the end of the rows (or start), and clicking on them would open a full-width row below the actual line containing all these details. Of course this would require a click to work (and another to close) but maybe it would worth it. But it's just an idea.

I did think about something like that, but thought I'd go for the simpler option first.

Surely I could just override text-transform to prevent the uppercase. Would you mind testing that in BatchChildEditor.css at around line 38? Or maybe I need to override the table#bceLanguages td rules?

Share this post


Link to post
Share on other sites

I'll check the text-transform thing tomorrow.

I got an error on loading the module settings, plus the language text on top is showing as a non-rendered markup (even if AOS uninstalled, if it's enabled it's not showing at all):

 

bce-language-markup.png

bce-error.png

  • Like 1

Share this post


Link to post
Share on other sites

Sorry, it looks like you downloaded as soon as I posted - I already fixed the "$this" issue is the version that is posted.

I'll look into the language text issue.

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 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!
    • By MoritzLost
      This module allows you to integrate hCaptcha bot / spam protection into ProcessWire forms. hCaptcha is a great alternative to Google ReCaptcha, especially if you are in the EU and need to comply with privacy regulations.

      The development of this module is sponsored by schwarzdesign.
      The module is built as an Inputfield, allowing you to integrate it into any ProcessWire form you want. It's primarily intended for frontend forms and can be added to Form Builder forms for automatic spam protection. There's a step-by-step guide for adding the hCaptcha widget to Form Builder forms in the README, as well as instructions for API usage.
      Features
      Inputfield that displays an hCaptcha widget in ProcessWire forms. The inputfield verifies the hCaptcha response upon submission, and adds a field error if it is invalid. All hCaptcha configuration options for the widget (theme, display size etc) can be changed through the inputfield configuration, as well as programmatically. hCaptcha script options can be changed through a hook. Error messages can be translated through ProcessWire's site translations. hCaptcha secret keys and site-keys can be set for each individual inputfield or globally in your config.php. Error codes and failures are logged to help you find configuration errors. Please check the README for setup instructions.
      Links
      Github Repository and documentation InputfieldHCaptcha in the module directory (pending approval) Screenshots (configuration)

      Screenshots (hCaptcha widget)

       
       

       
×
×
  • Create New...