Jump to content
thetuningspoon

Page Field Edit Links

Recommended Posts

Awesome!! It's already installed and working great on my personal invoicing system :) thank you, that's a great addition to PW and i think i will need this quite often!

One question: What do you think about an even more flexible way of defining the parent like i stated in my posting above. For example when i have a site for a sports club with different sections (soccer, tennis etc) and all of them manage their own chunk of persons.

tennis/data/john-doe

soccer/data/max-muster

now if i had a template "team" and wanted a pagefield to select the coach from the /data-children it should choose the corresponding page (/tennis or /soccer, depending on where the "team" page lives under). would a textarea like the "Custom PHP code to find selectable pages" be hard to implement?

oh, one more: as you seem to be a pagefield expert now, what would you think about an additional "unselect" button for the pagefield? https://processwire.com/talk/topic/9677-unselectclear-button-for-pagelistselect/

i think that would also be a great addition and would not harm anybody if you did it the same way like you are doing it with the view and add buttons (having to check the checkbox).

thank's for your great work! :)

Share this post


Link to post
Share on other sites

Hi BernhardB, glad you like it! This feature has been indispensable on my own projects as well.

If I understand correctly, it sounds like you need the ability to alter the parent page of new items based on the location of the current field in the page tree. Right now if you leave the parent option blank it should give you the option of where you want to add the page each time you create a new one. But I know this isn't ideal for what you want to do. I'll look into creating a Custom PHP field for that. I'm not completely sure if it's even possible, but my guess is that it shouldn't be too hard if I can look at how Ryan did it.

I agree that an unselect button would be nice. I haven't looked into how the page list select works under the hood, but it sounds like that might be a fun challenge if I can find the time to look into it. It might be as simple as adding a button and overlaying a bit of javascript to trigger the other button that's hidden in the list.

  • Like 1

Share this post


Link to post
Share on other sites

But I know this isn't ideal for what you want to do

jep ;)

unselect would be great - i tried it but i failed  :-X still have to learn a lot :)

custom php code would be the most flexible solution! it would even make the page select unnecessary ( return $page->get(/somepage); ) - but of course the page select you implemented now is much more user friendly, especially for non-coders :)

Share this post


Link to post
Share on other sites

Any opinion on the "View" vs. "Edit" link label?  Originally I had just changed it to "View" for one of my projects, but then I realized this might be clearer for the majority of applications, since "Edit" could imply editing the field itself rather than the selected page(s).

  • Like 1

Share this post


Link to post
Share on other sites

Thanks BernhardB. Have you had a chance to test the module with the new asmselect, and does it still work okay? I haven't had a chance to test the latest dev yet.

Share this post


Link to post
Share on other sites

Hi,

Today I had an issue with this module: I use it to create kind of library. All stored under "globals". There I can categorize things further like /globals/html and /globals/JavaScript... parent of selectable pages is set to "globals" and therefore this is used as parent for newly created pages. So every new page is stored under globals but it would be better to be able to choose the exact parent further down the tree under "globals"

Clear what I mean? :) don't know how that could be solved

Share this post


Link to post
Share on other sites

I think I know what you mean. Try changing line 119 in AdminPageFieldEditLinks.module from this:

$newPageParent = $event->object->newPageParent ?: $event->object->parent_id;

to this:

$newPageParent = $event->object->newPageParent;

Now just make sure that you are specifying a particular template and don't select a parent for new pages. Now when you click "New" it should now ask you where you want to put the new page, based on the template's family settings.

I haven't tested, so let me know if that works.

  • Like 2

Share this post


Link to post
Share on other sites

hi tuningspoon,

sorry can't test it because i was only working on this intranet project for the last week and had more important issues to deal with. it's ok to create pages under globals, link them and afterwards move them to their right location. the pagefield will keep the right reference.

thanks anyhow for your help i just wanted to mention this usecase maybe to keep it in mind for further updates. but i also think that this is a quite special one.

Share this post


Link to post
Share on other sites

I have an idea for an enhancement: for the "Enable + New link?" option it would be great if the newly added page was automatically selected in the Page field. Ideally it would show as selected immediately after closing the modal window (reload the Page field via AJAX?), or otherwise show as selected after saving/refreshing Page Edit. If a person is adding a new page from within Page Edit I think it's likely they want to select that option also.

I also noticed a quirk in that the "+ New" link is not rendered unless the "Enable view/edit link(s)?" option is also selected.

Share this post


Link to post
Share on other sites

I have an idea for an enhancement: for the "Enable + New link?" option it would be great if the newly added page was automatically selected in the Page field. Ideally it would show as selected immediately after closing the modal window (reload the Page field via AJAX?), or otherwise show as selected after saving/refreshing Page Edit. If a person is adding a new page from within Page Edit I think it's likely they want to select that option also.

Hi Cerulean. I definitely agree with your suggestion that the new page should be automatically selected when created. Unfortunately there isn't a straightforward way that I know of to do this, which is why I haven't done it yet. I am sure that it can be done (PageTable does something like it), but it will take me a while to figure out. Hopefully I will get some time to look at this soon since it is a feature I would like as well, and the "+New" link is a bit confusing without it.

I also noticed a quirk in that the "+ New" link is not rendered unless the "Enable view/edit link(s)?" option is also selected.

Thanks for the bug report. I'll look into this as well.

Share this post


Link to post
Share on other sites

Adding the new page to the inputfield is not trivial as the actual code does completely depend on the used inputfield. With a few 3rd party inputfields this will be quite some work if all of them should be covered.

  • Like 1

Share this post


Link to post
Share on other sites

@BernhardB - AJAX reload of the field sounds like a promising idea. I have not looked into how that works yet, but I will as soon as I get a chance!  

At this point I recommend only using the Add New feature if you're using the autocomplete field, since that doesn't require a page refresh to select the new item.

I saw your unselect module and it looks great :)

  • Like 1

Share this post


Link to post
Share on other sites

Could you implement a translation option for the javascript? (buttons ' New' and ' View'). I am really looking forward for the Ajax Solution to provide the new created page immediately.

Share this post


Link to post
Share on other sites

Currently working on an update with bug fixes, translatable links, and (hopefully) ajax refresh when new pages are added. I should have something ready tomorrow.

Edit: Made a lot of progress this weekend but will need a bit more time to iron things out. I was able to get the field to refresh when the Add New modal dialog is closed, which works great for single item selects and allows you to select the new item without refreshing the page. However, for asm-style multi-selects, the refresh wipes out your existing selection when it reloads. Because of this I think that another approach will be required.

  • Like 5

Share this post


Link to post
Share on other sites

I'm close to the finish line on this latest update. I've added support for ALL types of inputfields as well as automatic selection of a new page when it's added. I'm still working on the autocomplete inputfield and a few optimizations and then I will push the changes to GitHub.

  • Like 2

Share this post


Link to post
Share on other sites

New in version 3.0

Removes the limitations of the previous releases!

  • Now compatible with all Inputfield types including Select, SelectMultiple, Checkboxes, Radios, AsmSelect, PageListSelect, PageListSelectMultiple, and PageAutocomplete.

  • When using the create new page feature, new pages are added to the field and selected automatically as soon as the modal is closed. No further input is required from the user.

  • The "View" and "+ New" strings are now translatable

  • The add new page links may be enabled independent of the view/edit links

  • Code performance improvements

GitHub: https://github.com/thetuningspoon/AdminPageFieldEditLinks

Direct Download: https://github.com/thetuningspoon/AdminPageFieldEditLinks/archive/master.zip

I ended up using a combination of different methods for populating the field with the new page once it's created. Some of the input types were fairly easy and could be updated without reloading the field, while others required some pretty wild code acrobatics, taking advantage of Ryan's new AJAX reload and repopulating the input with pages that were already selected but not yet saved. Please let me know if you run into any bugs. This was built mainly in Chrome with limited testing outside of it so far, so I expect some issues.

I hope you guys enjoy the new features! Let me know if you have other suggestions for further enhancements.

  • Like 11

Share this post


Link to post
Share on other sites

If 'View/ Edit links on selected pages' is enabled this option should be hidden in case user has no edit permission for the selected page. Now an ugly error message is shown in the modal. Would be nice to not provide the link in this case.

Apart from this module is working properly under 3.0.8. Thumbs up and many thanks for the last fixes. :)

  • Like 2

Share this post


Link to post
Share on other sites

Ah, great point, kixe. I hadn't even considered permissions since it hasn't been an issue in any of my use cases yet. If you have a github account, would you mind adding this as an issue? Thanks.

Share this post


Link to post
Share on other sites

The latest update to this module is really great.

I notice that when adding a new page in the modal window the "Save" button does not close the modal like it does when using the native modal page edit feature (for AsmSelect). Could the Save button action be consistent with the native modal edit Save action, or do you think it's better to keep the modal open after save for newly added pages?

Share this post


Link to post
Share on other sites

Hi Robin, glad you are finding this module useful!

The reason why the modal stays open is that there are several scenarios in which I think this would be desirable. One is when you're creating a new page and it is a 2-step process. The modal needs to stay open after the initial page creation so that you can then edit the new page. The second is when there is an error on the page. I wanted the user to be able to see the error and make any corrections before closing.

Ideally, I would just have the modal stay open only in those scenarios, but accomplishing that in the PW admin isn't straightforward at this point. It is something that I would like to look into, though right now I'm pretty swamped with other projects.

  • Like 1

Share this post


Link to post
Share on other sites

Fair enough. Looking a bit closer at the native edit modal I see that the normal Save button is hidden and a replacement Save button is rendered as part of the modal frame. I don't see how that could work with a 2-step page creation process.

And keeping the modal open for errors is something I hadn't considered - it's actually a bit of a shortcoming of the native edit modal, which closes without displaying required field warnings, etc.

Share this post


Link to post
Share on other sites

The module is not compatible with PW 3.0.22. Please check. Module configuration is not loaded properly. If I can figure out details I will post here.

 

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 Macrura
      PrevNextTabs Module
      Github: https://github.com/outflux3/PrevNextTabs
      Processwire helper modules for adding page navigation within the editor.
      Overview
      This is a very simple module that adds Previous and Next links inline with the tabs on the page editor. Hovering over the tab shows the title of the previous or next page (using the admin's built in jqueryUI tooltips.)
      Usage
      This module is typically used during development where you or your editors need to traverse through pages for the purpose of proofing, flagging and/or commenting. Rather than returning to the page tree or lister, they can navigate with these links.
      Warnings
      If you are using PW version 2.6.1 or later, the system will prevent you from leaving the page if you have unsaved edits.
      For earlier versions, to avoid accidentally losing changes made to a page that might occur if a user accidentally clicks on one of these, make sure to have the Form Save Reminder module installed.
      http://modules.processwire.com/modules/prev-next-tabs/
    • 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-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 horst
      Croppable Image 3
      for PW 3.0.20+
      Module Version 1.2.0
      Sponsored by http://dreikon.de/, many thanks Timo & Niko!
      You can get it in the modules directory!
      Please refer to the readme on github for instructions.
       
      - + - + - + - + - + - + - + - + - + - NEWS - 2020/03/19 - + - + - + - + - + - + - + - + - + - 
      There is a new Version in the pipe, that supports WebP too: 
       
      - + - + - + - + - + - + - + - + - + - NEWS - 2020/03/19 - + - + - + - + - + - + - + - + - + - 
       
       
      -------------------------------------------------------------------------
       
      Updating from prior versions:
       
      Updating from Croppable Image 3 with versions prior to 1.1.7, please do this as a one time step:
      In the PW Admin, go to side -> modules -> new, use "install via ClassName" and use CroppableImage3 for the Module Class Name. This will update your existing CroppableImage3 module sub directory, even if it is called a new install. After that, the module will be recogniced by the PW updater module, what makes it a lot easier on further updates.
      -------------------------------------------------------------------------
       
      For updating from the legacy Thumbnail / CropImage to CroppableImage3 read on here.
       
      -------------------------------------------------------------------------
       
    • By Robin S
      Inspired by a recent question.
      Image Crop Ratios
      Allows preset aspect ratios to be defined per image field for the ProcessWire image crop tool.
      The module adds a select dropdown to the crop tool. Choose an aspect ratio and the crop area will be fixed to that ratio.
      Screencast

      Installation
      Install the Image Crop Ratios module.
      Configuration
      Default aspect ratios for all image fields can be defined in the module config. Aspect ratios for specific image fields can be defined on the Input tab of the field settings. You can override the ratio settings in template context if needed. Insert a hyphen as the first item in the ratio settings unless you want to force a ratio to be applied to the crop tool. The hyphen represents a blank option that allows a free crop area to be drawn. Usage
      Click the "Crop" link on the details view of an image thumbnail. Click the "Crop" icon at the top of the editor window. Choose an option from the "Ratio" select dropdown.  
      https://github.com/Toutouwai/ImageCropRatios
      https://modules.processwire.com/modules/image-crop-ratios/
×
×
  • Create New...