processwire / processwire-requests

ProcessWire feature requests.
39 stars 0 forks source link

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

Open klor opened 1 year ago

klor commented 1 year ago

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.
jmartsch commented 1 year ago

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.

Toutouwai commented 1 year ago

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
klor commented 1 year ago

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:

BernhardBaumrock commented 1 year ago

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