Jump to content

Page Field Select Creator


adrian

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

  • 6 months later...

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!

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

Link to comment
Share on other sites

  • 2 weeks later...

@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 :) 

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

  • 3 weeks later...
  • 4 months later...

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

  • 2 weeks later...

@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
Link to comment
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?

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

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

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

  • 1 month later...

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! :)

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
×
×
  • Create New...