Jump to content
Michael Murphy

Moving the "name" inputfield to content tab and how to regenerate all urls in a site

Recommended Posts

I think the name inputfield (used to generate page urls) is hidden away on the settings tab. The url is an important part of a website and I fear that most clients don’t ever see this, or forget about it when changing page titles.

Is there a way to move the name inputfield to the main Content area? Maybe below the title field - something like this screenshot :


Or alternatively, maybe the page name could be updated whenever the page title is changed (with an option to override)?

I recently had to regenerate all the urls in my site for various reasons. It was quite simple with the api - this was the code that I used


$pagesToCheck = $pages->find("template=playground|category");

$count = 0;

foreach ($pagesToCheck as $toCheck) {

$oldName = $toCheck->name;

//this creates the new url - use Sanitizer::translate if your titles have special characters
$newName = $sanitizer->pageName($toCheck->title, Sanitizer::translate);

if($oldName != $newName){

//print out the pages to be changed
echo $toCheck->title .' : '. $oldName . ' > '. $newName;
echo '<br />';

//replace the old url with the new one
$toCheck->name = $newName;

//save the page

$count ++;



if($count == 0){
echo '<p>looks like all urls have been updated!</p>';


Share this post

Link to post
Share on other sites

If u set advanced mode u can set an option on the template system or advanced tab to move name to content.

  • Like 1

Share this post

Link to post
Share on other sites

bad two raname aftar u.crated page

evry.time u raname a page.

u kill a link

may be

cd ..

Share this post

Link to post
Share on other sites

The main reason why name isn't on the content tab by default is because you could be breaking links (internal or external) every time you change it. It's one of those things that ideally should never change after its been created. But if you do expect changes, I suggest installing the Page Path History module, which will keep track of those changes and setup 301 redirects.

  • Like 2

Share this post

Link to post
Share on other sites

thanks Soma, I had never used the advanced setting before (whole new world!). It kind of solves the problem - the Name field gets added to the top of the content tab above the Title (and open by default). It does not appear that you can change the field description or placement.

I agree that changing urls is quite dangerous, but it's definitely something that editors should be more aware of when creating or changing content. I think this could be best solved with a simple module that displays the current url below the Title field.

The next thing I want to move is the "hidden" status option, which is another thing clients frequently ask (how do i hide a page?).

Share this post

Link to post
Share on other sites
The next thing I want to move is the "hidden" status option, which is another thing clients frequently ask (how do i hide a page?).

Instead of moving these things, why not teach the client how to use the 'settings' tab? These things are kept out of the 'content' tab for a few good reasons:

First is that they are things that are less likely to change after the page is created, so keeping them out of the content tab reduces the possibility of mistakes.

Second is that these are fields where changes are potentially costly. You change any one of the things on this page and you could affect navigation or site structure. This differentiates them from just about any custom field, which affect the content of the page, rather than the type or structure.

Third is that the fields in 'settings' are common among all pages, so it's a means of establishing a baseline consistency among all pages. Rather than the client having to figure out where 'name' or 'hidden' are, they know that no matter where they go, 'name' and 'hidden' are always in the same place.

I like to tell clients: "If you know how to edit one page, you know how to edit any page", and they find a lot of comfort in that. Since ProcessWire is driven by custom fields, it's possible for the editing scenario to change a lot from template to template. As a result, it's preferable (IMO) to have the page fundamentals (the things that are always there) kept together for consistency.

Share this post

Link to post
Share on other sites

we can teach clients how to do things, but that does not really lead to a better system. I would prefer to see how the client uses the system and then adapt it to what best fits their workflow. If i notice they are using the hide page functionality often, then perhaps this would be better placed somewhere else.

This is a pretty edge case scenario, so I may be wrong, but I’d like to test and see. I really think the most innovative area of CMS will be around improving the workflow and user experience for each client and specific project. This is something that PW already handles very well and I’d like to push it further.

Share this post

Link to post
Share on other sites

Michael, the status checkboxes actually can't be moved to the content tab. But you can add your own checkbox to perform a similar function. If you create a new field called 'toggle_hidden' (or whatever you want to call it) then you would just include "toggle_hidden!=1" in all of your $pages->find() calls.

  • Like 1

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 Robin S
      A new module that hasn't had a lot of testing yet. Please do your own testing before deploying on any production website.
      Custom Paths
      Allows any page to have a custom path/URL.
      Note: Custom Paths is incompatible with the core LanguageSupportPageNames module. I have no experience working with LanguageSupportPageNames or multi-language sites in general so I'm not in a position to work out if a fix is possible. If anyone with multi-language experience can contribute a fix it would be much appreciated!

      The module creates a field named custom_path on install. Add the custom_path field to the template of any page you want to set a custom path for. Whatever path is entered into this field determines the path and URL of the page ($page->path and $page->url). Page numbers and URL segments are supported if these are enabled for the template, and previous custom paths are managed by PagePathHistory if that module is installed.
      The custom_path field appears on the Settings tab in Page Edit by default but there is an option in the module configuration to disable this if you want to position the field among the other template fields.
      If the custom_path field is populated for a page it should be a path that is relative to the site root and that starts with a forward slash. The module prevents the same custom path being set for more than one page.
      The custom_path value takes precedence over any ProcessWire path. You can even override the Home page by setting a custom path of "/" for a page.
      It is highly recommended to set access controls on the custom_path field so that only privileged roles can edit it: superuser-only is recommended.
      It is up to the user to set and maintain suitable custom paths for any pages where the module is in use. Make sure your custom paths are compatible with ProcessWire's $config and .htaccess settings, and if you are basing the custom path on the names of parent pages you will probably want to have a strategy for updating custom paths if parent pages are renamed or moved.
      Example hooks to Pages::saveReady
      You might want to use a Pages::saveReady hook to automatically set the custom path for some pages. Below are a couple of examples.
      1. In this example the start of the custom path is fixed but the end of the path will update dynamically according to the name of the page:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'my_template') { $page->custom_path = "/some-custom/path-segments/$page->name/"; } }); 2. The Custom Paths module adds a new Page::realPath method/property that can be used to get the "real" ProcessWire path to a page that might have a custom path set. In this example the custom path for news items is derived from the real ProcessWire path but a parent named "news-items" is removed:
      $pages->addHookAfter('saveReady', function(HookEvent $event) { $page = $event->arguments(0); if($page->template == 'news_item') { $page->custom_path = str_replace('/news-items/', '/', $page->realPath); } }); Caveats
      The custom paths will be used automatically for links created in CKEditor fields, but if you have the "link abstraction" option enabled for CKEditor fields (Details > Markup/HTML (Content Type) > HTML Options) then you will see notices from MarkupQA warning you that it is unable to resolve the links.
      Install the Custom Paths module.
      The custom_path field is not automatically deleted when the module is uninstalled. You can delete it manually if the field is no longer needed.
    • By AndZyk
      I am currently building a intranet which will be hosted on the local network of a company. This intranet has many links to files on their fileserver with the protocol file://.
      So for example the links look like this file://domain.tld/filename.ext
      When I try to insert such a link into a URL field, I get the error, that only the protocol http:// is allowed. When I try to insert such a link into a CKEeditor link, it gets stripped out. Is it possible to insert such links into the FieldType URL and CKEditor.
      I know that I could use a FieldType Text or insert a RewriteRule in the .htaccess file, but I am looking for a more elegant solution. 😉
      Regards, Andreas
    • By stanoliver
      The following code snippet is part of my markup simple navigation and the url_redirect (url field in the backend) just works fine when I put an special custom url into the url_redirect field.
      <?php $nav = $modules->get("MarkupSimpleNavigation"); // topnav $current = $page->rootParent(); // current root page // subnav echo $nav->render(array( 'max_levels' => 2, 'item_tpl' => '<h4><a class="g8-bar-item g8-hover-black" href="{url_redirect|url}">{title}</a></h4><hr class="sidenav">', 'collapsed' => true, ), $page, $current); ?>  In my seperated breadcrumb navigation I use the following code snippet
      <?php foreach($page->parents()->append($page) as $parent) { echo "<li><a href='{$parent->url_redirect|url}'>{$parent->title}</a></li>"; } ?> Now to the problem: In my first code snippet above the
      works just fine but when I try something similiar in the second code snippet
      I produce an server error How do I have to change the second code snippet so that it works in the correct way as the first code snippet does?
    • By gregory
      Hi everyone.
      I can't see the PDF uploaded via a field called "pdf".
      I get a url like this: http://localhost:8888/mywebsite/site/assets/files/1129/test.pdf%EF%BB%BF%EF%BB%BF
      Could anyone help me? Thank you.
      <?php foreach($page->case_studies as $item) { if($item->type == 'contenuto') { echo " <a class='btn btn-primary btn-sm' target='blank' href='{$item->pdf->first()->url}' role='button'>Download</a> "; } } ?>  
    • By ce90
      Hello everyone,
      hopefully this is the right place to ask and is not a duplicate question.
      I'm pretty new to processwire, so... if this question is kind of funny for some of you, you're welcome 😄 
      I have the following issue and can't find anything understandable about it. Maybe I'm searching the wrong way, but anyways.. here is my question:

      How is it possible to rewrite the URLs, that I'll get a *.php ending?
      https://www.mysite.de/urlsegment/ -> https://www.mysite.de/urlsegment.php
      https://www.mysite.de/urlsegment/urlsegment/ -> https://www.mysite.de/urlsegment/urlsegment.php
      Because I've read a lot about "Why do you wanna do this or have that?" – here my answer for that in advance:
      I've built a processwire installation inside or around an existing website. Therefore, we want to keep the existing *.php Google entries. Sure, we could redirect via 301 Redirect, but would prefer to keep the *.php ending.
      If you have further questions, please do not hesitate to ask.
      Thank you in advance for your help.

      Best regards
  • Create New...