processwire-requests icon indicating copy to clipboard operation
processwire-requests copied to clipboard

Support "Add New Page"-urls that specify the desired page template -> "/processwire/page/add/?template=skyscraper"

Open klor opened this issue 1 year ago • 4 comments

Short description of the enhancement

As a webmaster, when I'm on the Skyscraper listing page and have the possibility to create a page using, say, Skyscraper, City, and Architect templates, then I want to click a link in the front-end navigation that allows editors to create a Skyscraper page directly, without having to choose template first (same for City and Architect).

This might be achieved by appending "?template=skyscraper" to the url (it seems this is currently not supported)

<a class="navbar-item" href="/processwire/page/add/?parent_id=<?=$page->id?>&template=skyscraper">Add Skyscraper</a>

Current vs. suggested behavior

Current behavior:

When designing a ProcessWire site, I usually create a dropdown in the front-end that allow editors to quickly go to the Page Tree, Edit page, and add additional pages. Problem with adding pages is that I cannot specify the exact template to use. So, this is what the editor needs to do:

Step 1: image

Step 2: image

Suggested behavior

Step 1: Add direct "Add New Skyscraper"-links, yeah! image

Why would the enhancement be useful to users?

Webmaster can create links in the frontend that makes it easier for novice user as well as lazy admins to create pages.

PS: ChatGPT think this is possilbe (or maybe I'm missing a setup step?)

To create a link that takes the editor directly to the Skyscraper template, you can modify the URL in your code to include the template parameter with the value set to the name of the Skyscraper template.

Assuming the name of the Skyscraper template in your ProcessWire installation is "Skyscraper", you can modify the URL in your code as follows:

<a class="navbar-item" href="/processwire/page/add/?parent_id=<?=$page->id?>&template=skyscraper">Add Skyscraper</a>

This will create a link that, when clicked, will take the editor to the "Create New" page with the Skyscraper template pre-selected. The editor can then fill out the fields and create a new page using the Skyscraper template.

klor avatar Apr 02 '23 09:04 klor

If you set "Allowed templates for children" to a value, then the step of chosing the template would be skipped, if you only referenced one child template. If you use multiple possible allowed templates for children, then you would still have to chose. image

So I think it could be a good improvement.

jmartsch avatar Apr 03 '23 09:04 jmartsch

This feature already exists. You use "template_id" in the URL to specify the ID of the template.

Example:

/processwire/page/add/?parent_id=1234&template_id=29

Toutouwai avatar Apr 03 '23 10:04 Toutouwai

Adding &template_id=29 works like a charm <3, thanks @Toutouwai

Case closed (on my side, Ryan may have a comment)

PS: @ryancramerdesign - May I suggest that Admin url parameters are documented, something like:

  • Page Tree
    • open - Opens Page Tree. Example: https://www.example.com/processwire/page/?open=11994
  • Edit Page
    • id - Specifies ID for page being edited. $page->editUrl outputs such a url. Example: https://www.example.com/processwire/page/edit/?id=12022
    • language - $page->editUrl outputs such a url when Language Support / multi-language is enabled. Example: https://www.example.com/processwire/page/edit/?id=11888&language=1010
  • Add Page
    • parent_id - Specifies that current page will have parent_id as Parent. Example: https://www.example.com/processwire/page/add/?parent_id=11994
    • template_id - Opens Add Page with selected template. Example: https://www.example.com/processwire/page/add/?parent_id=11994&template_id=120
  • etc.

klor avatar Apr 04 '23 09:04 klor

Yeah or maybe a blog post about all the available parameters would be nice!

BernhardBaumrock avatar Apr 04 '23 09:04 BernhardBaumrock