Jump to content

Page urls with auto-incrementing IDs (and without Page Name parts)


Recommended Posts

I love nice urls - but I also recognize that they are not always needed nor desired due to the additional steps in page creation.

Suggested solution:

  • Page ID
    • Page ID is a per-template auto-incrementing number.
    • No. series might be added on a per-template basis (to be configured by webmaster).
  • Page url
    • Replace the full page url with an ID (as an optional configuration).
    • Page url might then change to something like: www.example.com/page/1234
  • Editing
    • (Page Tree is much less important in this scenario.)

Like Drupal's Node IDs (nid).

Why this change? Name may reveal confidential info. Name may not matter on certain templates. Page creation is no longer a two-step process; much like adding a row in MySQL.

Benefit: This change will make it easier to use ProcessWire for other purposes than websites ("Oh - so ProcessWire is also a finance system!").

Link to post
Share on other sites
8 hours ago, SwimToWin said:

Page url

  • Replace the full page url with an ID (as an optional configuration).
  • Page url might then change to something like: www.example.com/page/1234

 

At least this part can be done with a simple hook 🙂 

// site/ready.php
$wire->addHookAfter("Pages::saved(template=foo)", function($event) {
  $page = $event->arguments(0);
  $page->name = $page->id;
});
  • Like 1
Link to post
Share on other sites
  • 1 month later...

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 Peter Knight
      Hi 
      I have a list of pages all based on the same template but I want to exclude 2 by page ID
      $expertises = $pages->find("template=case-type, sort=sort"); foreach ($expertises as $expertise); I know I could change their template or add an exclude checkbox to the template etc
      Wondering if there is a page=not(4989,9877) type of thing in the API to exclude pages by ID?
      I can't find anything in the API docs but think I may be searching for the wrong phrase.
      Thanks
    • By milo695
      Hi all,
      I need help creating link in CK editor that would target my translated page, so it depends on what language user has selected.
      something like:
      <a href="?id=1450">view all</a> would target:
      <a href="en/onion/">Onion</a> <a href="de/zwiebel"></a> depending on user defined language.
      Thank you
    • By SwimToWin
      When webmaster un-globals the Title field (for instance to have a person template with first and last name), there are some unintended consequences. For a site that uses Title on 90% of templates, un-global isn't really useful because it makes adding a new page harder for novice editors:
      Title field disappears from "Add New" dialog. When I "Add New" page using a template that DOES use the Title field, then the Title field is no longer shown in the Add New dialog window (in this window, an editor will enter Title and Name - and the page is then created and shown to the user in edit mode). No other "pseudo-title" fields can be added to the "Add New" dialog (and it's not possible to skip the two-step page creation process). (There is no simple way to pre-populate the Title field on templates.) Consider these flows:
      When Title field is global:
      Steps:
      From Page Tree, press New to create a new page, "Add New" page is shown with Title and Name fields, (User may need to select Template) Enter Title (Name is automatically set), The new page is shown - start editing fields Observation: Title and Name are shown on same page (good!). Page is created with little mental effort.
      When Title field is un-global and Page Template has a Title field:
      Steps:
      From Page Tree, press New to create a new page, "Add New" page is shown with Name field (but Title is no longer shown when template DOES have the Title field), (User may need to select Template) Enter Name, The new page is shown - start editing fields ("where am I?"). Enter Title (user no longer sees Title and Name at the same time) Observation: Redundant entries (Name and Title are often identical). Name and Title are separated across pages.
      Better: Show Title and Name on "Add New" page, use Title to set Name (as when Title field is global).
      When Title field is un-global and Page Template doesn't have a Title field:
      Setup:
      Webmaster goes to Template -> Advanced to set "List of fields to display in the admin Page List" (example: "{foo} - {bar}"). Thanks to Robins S for pointing this out. Webmaster cannot specify "Title" fields to be filled in on the "Add New" page. Steps:
      From Page Tree, press New to create a new page, "Add New" page is shown with Name field, (User may need to select Template) Enter Name, The new page is shown - start editing fields ("where am I?"). Better: Setup allows webmaster to specify "Title" fields to be filled in on the "Add New" page.
      Even better:
      Skip the "Add New" dialog page and go directly to the resulting Title page (when only one Template can be selected).
      Maybe by adding a GUID or other temporary page name that is later renamed?
      Also I don't think it's possible to pre-populate the Title field in the Administration? (for details, see Pavle's comment).
      See also: Creating a page without a title? (from 2012 - so I think it's OK to begin a new thread).
    • By SwimToWin
      Skip the "Add New" dialog page on Page Tree and elsewhere and go directly to the resulting page that shows all page fields right away. Page creation is now improving from being a two-step to becoming a one-step process.
      Scenarios:
      When only one Template can be selected: Skip the intermediate "Add New" dialog page by adding a GUID or other temporary page name that is later renamed. Show the final editing page so user can start editing all fields right away On Save: Page name is renamed with title When multiple Templates can be selected: Ask user to select Template on clicking New (before leaving the Tree Page). Then use the "one Template" flow above. (I am aware why the Page Name is needed.)
    • By ridgedale
      Reference: PW 3.0.111 and uikit3 based site using the Regular-Master profile.
      I am trying to create a process whereby when a user logs in to their profile page (the user is automatically redirected to their profile page on login) and they then go to their 'members' page and creates a child page ('club-member'), the data stored in the user template ($user->usercode) is automatically added to the equivalent field on the club-member page.  This will be applicable only to the template used for the 'club-member' pages. Once the new page has been created the equivalent 'usercode' field on the 'club-member' page should not be subsequently editable.
      Below is the page hierarchy for visual reference:
      Login (home)
          |__  profile
                      |__  members
                                     |__  club-members
      It seems like an AddHookBefore might be the solution here such as:
      wire()->addHookBefore("Pages::saveReady", function($event) { $page = $event->arguments(0); if($page->template == 'club-member') { $clubcode = $user->club_code; $field = $page->club_code; $field->set('value', $clubcode); } }); I am I on the right track or is there a better way to achieve this?
      Any thoughts appreciated.
×
×
  • Create New...