Jump to content

New page from inputfield


statestreet
 Share

Recommended Posts

Often, the pages I find myself referencing in a page field (whether through asmSelect or otherwise) are very simple. They might be categories, tags, or something along those lines, but they only contain a single text field. In cases like these, it would be great to be able to add new ones from the page that contains the referencing field.

So if, for instance, I were adding a new page to a site, and had a "topics" field that selected pages from /topics/, and I realized that topic didn't exist yet, I could add it from the page without having to go back to the page tree, navigate to /topics/, create a new topics page, publish, then return to my unpublished new content page.

I suppose the most straightforward plan of attack would be to create a new inputfield module, but ideally, this could be applied to any of the existing ones, whether checkboxes, asmSelect, or auto complete. Can a module extend other modules in that way?

Link to comment
Share on other sites

I agree, it would be very handy and I've been wishing for this on many occasions too. Most likely we'd just add it to InputfieldPage, which is the container Inputfield for all Page selection inputs. I will put some more thought to this to see how we might implement it.

Link to comment
Share on other sites

We had similar thoughts about it a couple of days ago here

The only thing that's missing to make workflow really handy is, as Pascal said, a possibility to create new pages (building blocks) instead of just being able to select them.
Link to comment
Share on other sites

I wonder, could this use something akin to the fieldset-in-a-fieldset approach that repeaters now use? Perhaps it could even just replicate all the fields from the referenced template inside inside a fieldset in the page field, so while it might be best-suited to creating new pages with only one or two fields in their templates, it could expand to any template a page happened to use.

Link to comment
Share on other sites

I think that even for slightly more complex pages it could be useful to throw up a modal window that goes through the process of adding that page as you would normally.

I've got a few fields on one project where it's more than just a title, so whilst I would like to see a simple option for fields that are just linking to a page with a title I think that being able to add a more complex page would be hugely beneficial.

What I wouldn't want to do is have the ability for someone to add a new page title and then forget to fill out the rest of the page after saving the current page, but I think that displaying a large page inline like with the repeater fields could get messy - especially since you need to take into account that page's tabs too.

That's the only reason I was thinking of a modal window for it :)

Link to comment
Share on other sites

I don't know, modal windows sound messy too, but maybe that's just because I've been scarred by WordPress's cumbersome image insert boxes. :)

Any way you go about it, you're probably looking at a somewhat less-than-ideal situation if you're adding a page with lots of fields while editing another page that references it. If it has enough fields that a user might forget to fill some of them out, it's probably worth going the long way around instead of trying to add it in-context.

Link to comment
Share on other sites

I have this setup and working, so should be able to commit it to the source here within the next few days. While I think there are a lot of good ideas here with regard to how to go about it (and possible future directions), I'm taking the quick+simple route for now. This will solve the majority of adding-page-reference needs for me at least. So the way this is setup, you could paste in a few hundred pages to add if you wanted to. Also, this works with all the page reference inputfields (checkboxes, selects, asmSelect, radios, autocomplete, PageListSelects, etc.) This was easy to do, because InputfieldPage is already serving as a container Inputfield for all the others, so it was just a matter of having that module append to the output of the selected inputfield module. Check out this brief demo:

In order to use it, you check the box on your page reference 'input' tab settings, like shown in the video. Your page reference field has to have both a parent and template defined with it. It also has to use the 'title' as the label field (which 99% of the time I'm sure we already do). If the user doesn't have access to create new pages in the parent or with the template, then the option to add new pages won't appear.

If used with an inputfield that only allows selection of a single page (rather than multiple pages) then it gives you an <input type='text'> rather than a <textarea>, since you can only add/select one page in that scenario.

Link to comment
Share on other sites

I'm just thinking wouldn't it better to be able to really create the page in a modal dialog of a template specified? I'm thinking because if I often need to create multi-language page and in case of categories I use multiple title fields one for each language. This way with new lines is suited well for things like names that would be neutral.

Link to comment
Share on other sites

I really like this functionality and in a lot of situations the implementation based solely on titles will suffice and additionally has the benefit of being able to add/paste in multiple items at a time.

But at the same time i gotta agree with Soma: quite often the page(template) you want to reference has more than one field you will want to populate. From a UI- and fast workflow perspective it would be great if this was possible. I guess this would mean some sort of modal popup. As the PW user-base expands i think this would be frequently used and a killer feature, really taking the relational aspect a step further (from UI perspective).

So for possible future directions, and to make PW even more awesome than it already is i ask you to take this into consideration.

Link to comment
Share on other sites

I totally agree it would be great to have a modal dialog that then creates pages and all their fields. But there is a rather large difference in development time between that and what I've added. I added what I could afford to in the short term. Down the road, I'm sure we'll expand the capability to take the modal route when dealing with creating pages that have more than just a title field. But since I could add the title-only page additions in the short term, I figured that's a good place to start. Even when we expand with the modal dialog, I do want to keep the current method for when the template has just a title field. The reason is that this is a very convenient way to create large selects. Lets say you need a "country" select -- you can paste all 196 countries into that field and create all your select options in one shot.

  • Like 3
Link to comment
Share on other sites

This feature is now available in the latest commit. Please let me know how it works for you guys. You will see a new checkbox option available with page reference fields when editing them under: Setup > Fields > Edit: [your-field] > Input [tab] > "Allow new pages to be created from field?". It includes instructions on the required settings for it to be active.

  • Like 1
Link to comment
Share on other sites

  • 4 months later...

I use this feature to makes tags on my site. However, now that I have more tags, these checkboxes are listed in chronological order and become hard to find. It would be nice if they were in alphabetical, or if I were able to choose how they were sorted.

maybe PW 2.3 could add a feature to sort all child pages when listed in the admin (when there are many it becomes hard to move them all around one by one).

Link to comment
Share on other sites

I'm not 100% sure I understand the question, so let me know if I'm answering the wrong thing.

The behavior here depends on how you've defined your selectable pages, as well as what inputfield you've selected. The PageList inputfields will sort in the same way your page tree does. Whereas the others will sort according to the selectable pages definition. If you chose a parent for the selectable pages, then they should sort according to the parent's sort setting (on it's children menu). If you are using some other criteria to find selectable pages (like template, by itself), you may want to instead use the "custom selector to find selectable pages", and specify the "sort=field" right there, i.e.

template=something, sort=title

When you add a page to a multi-page selection, where it goes in that selection depends on what inputfield you are using. If using asmSelect, PageAutocomplete, or PageListSelectMultiple, new selections are appended to your list and you can drag-n-drop them wherever you want them to be. If using checkboxes or regular select multiple, then the selection should stay consistent with the source.

Link to comment
Share on other sites

ok, I'm so sorry for wasting your time... it is a really simple setting.

my new pages made by inputfield were put under the parent 'tags'.. so in the admin tree, I just needed to click tags > edit > children... then there is a sort setting there.

I never knew that setting existed, another win for PW usability.

Thanks Ryan~!

  • Like 1
Link to comment
Share on other sites

  • 4 years later...

Hey guys, 

   I am struggling with "new page from input field" feature.  I think I have made correct settings, but when I go to create a new page, it shows me a list of existing pages, but not an option to add a new page. 

This is my setup. I have three pages: Story, Categories and Category. Categories is the parent of Category page.

In story page, I have a field called categories of type "page". For this field, in "Input" section, I have followed the instructions to allow new pages to be created from field. 

1. Both a parent and template must be selected above. -- The parent is set to Categories, and template is set to Category. 
2. The editing user must have access to create/publish these pages.  -- YEs.
3. The label-field must be set to "title (default)". -- It is set to title (default)

See the attached screenshot for the field settings. 

The interesting thing is -- if instead of Categories, I select "home" as the "parent of selectable pages," it works. I then see the option to add new page. But I want the parent to be Categories. I have also compared my categories field settings with  "architects" field setting in skyscraper demo.

I am missing something somewhere, but cannot point to it. 

Any suggestions?

thank you

 

 

 

categories.png

Link to comment
Share on other sites

Are you sure all permissions are set up correctly? Have you restricted template relationships (in the Family tab of Category and Categories template settings)?

Also try setting other than PageListSelectMultiple, the notes say it's incompatible (see the second to last setting in your screenshot). I suppose it works with Home by accident only.

Link to comment
Share on other sites

I think I have the restrictions  right. Attached are the screenshots of the family sections of category and categories template.

I am now using InputfieldChosenSelectMultiple instead of PageListSelectMultiple -- no difference. 

thanks,

categories-template.png

category-template.png

Link to comment
Share on other sites

No idea then. If you can't see the add new field with admin rights then it's surely not a permission issue.

Have you tried uninstalling the inputfiedchosen module to see it helps? (or any other module you installed to make this work)

Link to comment
Share on other sites

1 hour ago, tpr said:

Also try setting other than PageListSelectMultiple, the notes say it's incompatible (see the second to last setting in your screenshot).

For the record, PageListSelectMultiple does work with "Create New".

select-multiple.png

Link to comment
Share on other sites

OK, I finally got it to work after several trial and errors. 

It worked after I removed "allowed template(s) for children" under categories. Earlier, I had it set to Category -- just the way "Architects" template had it set to "architect" in skyscraper demo. Attached is the screenshot of my new settings. 

I am unable to tell why it worked, but it did. Maybe it is due to some mis-configuration elsewhere. I will keep digging.

thanks everyone for help.  

categories-updated.png

Link to comment
Share on other sites

It seems strange to me that in your screenshots of the Family settings of Template Categories none of the radio options is ticked. Something wrong with that?

(Of course, the Categories page must have children allowed.)

  • 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...