Jump to content
adrian

Page Field Select Creator

Recommended Posts

The multi language input can get very easy out of sync when the list of added children is long.

I think when you're building a multi language site it's saver to to just foreach the already created list (childpages) with custom code

and provide for every (each) translation a input field. ( easy the write from your template )

I love the module how it is now. I think you shouldn't overcomplicate it.

<adrian>PS Excuse the dodgy google translations</adrian>

I google it all the time, I can't even write :-)

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the feedback on that - sounds like you have a better solution anyways!

In case you, or anyone else misses the note in the edited first post, it is now available from the modules directory:

http://mods.pw/5R

Thanks again Martijn for all your help testing this - much appreciated!

  • Like 1

Share this post


Link to post
Share on other sites

I installed this and my question is: the suffix for the child page - is it editable after creating?

What exactly can I do with this module?

I need for example many selects, and I need to make main pages and sub-pages for a page-field type to have a select on:

Province

City

Branche

Company

etc.

All with near 20 values.

ps. it would be nice if the Parent Page could also be created on the fly!

Share this post


Link to post
Share on other sites

Hi bwakad,

Do you mean the name of the child template suffix? That is configurable in the module settings, but there is also no reason why you can't change the name of the template itself after creation - like any other template, go to the Advanced Tab > Rename Template.

The parent page for the list of options (the child pages) is created on the fly - it matches the field name. If you are referring to the page selector called Parent Page - I don't think it makes sense to be able to create this on the fly - it can be the Home page, or a hidden options or tools, or selects page - somewhere where to store a whole range of pages that aren't part of the site tree.

I would recommend filling out the fields in the module and you can see exactly what happens. You'll end up with a field (such as Province) that you can then add to your required template and the content for the select will automatically be linked to it.

Try it out and then me know if you still have questions or suggestion for improvements.

Share this post


Link to post
Share on other sites

Actually, I was looking for something to have FIRST select prefill the SECOND select based on value of FIRST select - and then give me the fields and all.

States and Cities for example.

Share this post


Link to post
Share on other sites

@adrian

After drawing up a spec. on the back of an envelope (ok, back of a timetable) for a module to allow the fast creation of sets of pages plus the templates and fields needed for them I decided to browse the modules repo and found your module. Thanks for saving me some time with this one :) 

Share this post


Link to post
Share on other sites

No worries - I haven't revisited this one in a while, so please let me know if you think of any improvements. I know the soma is not keen on the fact that currently you can't reuse templates as each new page field creates a new paired set of parent/child templates. So maybe I should aim to add an option for that, but I am definitely curious to hear your feedback.

  • Like 1

Share this post


Link to post
Share on other sites

@adrian

Just started using this on a test install and it's fantastic.  :D

I agree with Soma that being able to choose a template for the parent (container) page would be good as I can envisage using a common container template for different sets of children.

I think your module would also benefit from allowing user override of the generated parent and child template names. For example, I'm going to be doing a site offering different gymnastic courses so a natural name for one of my containing parents is going to be 'Courses' which gives rise to the template name of 'courses' (which is fine) but I'd like the template for the children to be the singular 'course' rather than 'courses_items'. You could probably accomplish this by providing a field for the child template title and having it filled on-the-fly as the parent title is edited in the same way a page name is populated as the page title is entered (if not already edited by the user.)  The workflow would then look something like...

  • Enter the parent title: "Courses" (the child title automatically becomes "Courses Items" by default.)
  • Edit the child template title, changing it to "Course".
  • Fill in the rest of the page & submit giving parent template title: "Courses" and name: "courses", child template title: "Course" and name "course".

In this way, users could title and name the parent and child templates as needed. The child template title field could be collapsed by default as it can safely be ignored if the user isn't picky about the child template title/name.

Not sure how easy or difficult this might be but having a way to specify field types when using option 2 might be useful too. Maybe something like...

Title, Min Age>Integer , Max Age>Integer, Gender

Though there will be better ways to express this.

I'll keep playing and post again if anything more comes to me.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks Steve,

I'll see what I can do about incorporating these changes.

  • Like 1

Share this post


Link to post
Share on other sites

Wow, Adrian, I am such a clutz for having not spotted this Module before, thanks SO much for creating it! ^_^ Cheers, -Alan

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the kudos. Hope you enjoy it.

I am hoping to get to those improvements that Steve suggested sometime soon, but just completely swamped here at the moment!

  • Like 2

Share this post


Link to post
Share on other sites

Just wanted to let everyone know that I finally got around to implementing netcarver's suggestions!

You can now choose to override the parent and child template names from two collapsed fields. If left blank, behavior is as previously - they will be named based on the field name and the suffix supplied in the module config settings.

You can now optionally define the field type when using Option 2, eg:

Title, Number of Beds>Integer, Number of People>Integer, Kitchen Facilities>Text
Single, 1, 1, Fridge Only
Double, 2, 2, Fridge Only
Suite, 3, 6, Full Kitchen
 
Please let me know how this new functionality works out for you - I am hoping that now there will be no reasons to ever create a Page field setup manually, but let me know if I have missed something that anyone still needs.
  • Like 3

Share this post


Link to post
Share on other sites

Why did I see this just after setting up four kinds of categorizations on my current project. Next time I need it, I'll install this module.

  • Like 2

Share this post


Link to post
Share on other sites

@adrian

Thank you very much for the update. I've been trying it out and overall, it's excellent! However, I think I might have found an issue. On every child page created using the module I'm seeing a new, untitled field at the foot of every page (I'm trying this in 2.5.1dev using the Reno theme.) Here's an example...

post-465-0-14993200-1411242522_thumb.png

  • Like 1

Share this post


Link to post
Share on other sites

Hey Steve,

Sorry about that - I am assuming you are using Option 2 to create the selectable child pages. I am guessing there is a problem with my parsing of the comma separated field names / line breaks. I went for a very rudimentary approach instead of str_getcsv :)

Can you send me the text you are using to create your pages so I can try to duplicate?

Share this post


Link to post
Share on other sites

Hi Adrian,

Here it is...

Title, Tel>Text,
Steve, 

...and I think I see the issue. There's a trailing comma with no fieldname after it on the first line. Stupid typo on my part but probably something you'll need to catch and handle when parsing the string.

  • Like 1

Share this post


Link to post
Share on other sites
There's a trailing comma with no fieldname after it on the first line

Yeah, that would be the problem ;)

I'll sort out a fix for that sometime later today when I get a spare minute.

Thanks for discovering the issue.

As you use it more, also please feel free to send through any other suggestions for improvements. I have to admit I am really enjoying the changes to suggested - it does make things cleaner!

  • Like 1

Share this post


Link to post
Share on other sites

<2¢>

Can only add a tiny idea at the moment. Currently the "Child Template Name Override" field says...

Only use this if you want to override the automatically generated template name which is based on the field title plus the child template suffix in the module config settings. Use capitals, spaces etc as this will be used for the template label as well.

Seeing as your module knows what the suffix is, why not either

  1. tell the user what the template will be called if they don't enter a value or...
  2. make the field required and setup the value to what will be used?

In either case your users get to see exactly what will be used for the template and can change it if they don't like it. At the moment they have to guess or else navigate away from the page in order to see if they like the template name that will be used.

</2¢>

Share this post


Link to post
Share on other sites

Thanks again Steve - great 2¢ suggestion :)

I have set it up using your second option and I think it works great. 

I have also added a fix for the blank fields / extra commas issue.

Please let me know if you find any problems with it.

  • Like 1

Share this post


Link to post
Share on other sites

Hi Adrian,
 
The 2¢ solution seems to be working just great. I'm still getting the stray field at the end of the child templates with 0.1.8 though.

post-465-0-48199800-1411285142_thumb.png

The field it creates looks quite interesting in the child template...

post-465-0-12742900-1411285401_thumb.png

Edited to add: I think I found the issue. I've added a comment to your repo, here, about it and also opened an issue against PW to allow incompletely defined fields to be deleted via the admin interface.

Share this post


Link to post
Share on other sites

Thanks again!

I just spent some time revisiting this a bit. It's a bit more complicated that just removing trailing, commas, spaces, tabs etc because it is possible that these might be intentional if someone wants an empty value for the last field on the row.

I have implemented a bunch of extra checks to make sure fields/pages etc can't be created without a name, so you shouldn't ever get the unnamed field issue anymore. I have also tried to make sure that the first row has no leading or trailing misc stuff so that the fields get properly created. But with the subsequent rows I allow trailing commas with nothing afterwards in case it is meant to be blank.

I just tested with this mess and it looks to be fine:

, 
,Title, Number of Beds>Integer, Number of People>Integer, Kitchen Facilities>Text
,Single, 1, 1, Fridge Only, 

Double, 2, 2, Fridge Only
Suite, 3, 6, Full Kitchen
,

Would you mind trying again at your end to see if I have still missed something?

Thanks

Adrian

  • Like 2

Share this post


Link to post
Share on other sites

@adrian

Works great here now. Thank you for the work on this module!

No problem at all - thanks for all the input and ideas!

Share this post


Link to post
Share on other sites

Just a thought:

maybe by default the item template should NOT have the show in add new shortcut menu set to yes, but rather to no.

Or have that option as part of the create form.

I have just had an interesting selection of things appear on my add new button! :)

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 bernhard
      --- Please use RockFinder3 ---
    • 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 (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
    • By MoritzLost
      Sorry for the convoluted title. I have a problem with Process modules that define a custom page using the page key through getModuleInfo (as demonstrated in this excellent tutorial by @bernhard). Those pages are created automatically when the module is installed. The problem is that the title of the page only gets set in the current language. That's not a problem if the current language (language of the superuser who is installing the module) is the default language; if it isn't, the Process page is missing a title in the default language. This has the very awkward effect that a user using the backend in the default language (or any other language) will see an empty entry in the setup menu:

      This screenshot comes from my Cache Control module which includes a Process page. Now I realize the description sounds obscure, but for us it's a common setup: We a multiple bilingual sites where the default language is German and the second language is English. While the clients use the CMS in German, as a developer I prefer the English interface, so whenever I install a Process module I get this problem.
      As a module author, is there a way to handle this situation? I guess it would be possible to use post-installation hooks or create the pages manually, but I very much prefer the declarative approach. The page title is already translatable (through the __ function), but of course at the time of installation there is no translation, and as far as I'm aware it's not possible to ship translations with a module so they are used automatically. Could this situation be handled better in the core? I would prefer if the module installation process would always set the title of the Process page in the default language, instead of the language of the current user.
×
×
  • Create New...