Wikimedia Developer Support

Make wiki urls use page IDs instead of page titles?

Is it possible to make MW pages have their ID in the URL instead of the page title?

E.g. the page ‘Test’ would be htttp://???com/wiki/516881812 instead of htttp://???com/wiki//Test

The reason I’m asking that is because I want to create a wiki where each user can submit projects, and I don’t want to worry about name conflict (e.g. two people want to create the project named ‘Test’).

Moreover, I want to give my users the ability to change the page title (i.e. their project title) on their own, without having to ‘move’ the page to a new title.

1 Like

Urls can be by pageid using the ?curid parameter, but it can’t be the default, and you can’t have conflicting names.

I think people who want to do what you describe, usually use https://www.mediawiki.org/wiki/Extension:Display_Title in combination with SMW or Cargo, and have every page title just be a unique number, but have it displayed as something else.

1 Like

Thank you for that. I will try it.

When I go to add a new ‘project’ through the Cargo form, it asks me for a project name. If I try to add the project ‘Test’ when it already exists, it just redirects me to edit the old project. Do you, or anyone else, know how to make Cargo NOT take the project name as a page name, and instead assign a unique page number as you said?

You could do it with PageForms, something like the following in Form:Project:

{{{info |page name=P<unique number> }}}
{{{for template|project}}}
Project title: {{{field |title }}}
<!-- Rest of the form here. -->
{{{end template}}}
1 Like

Thank you for the reply.

this was the original form

<noinclude>
This is the "Project" form.
To create a page with this form, enter the page name below;
if a page with that name already exists, you will be sent to a form to edit that page.


{{#forminput:form=Project}}

</noinclude><includeonly>
<div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div>
{{{for template|Project}}}
{| class="formtable"
! Type: 
| {{{field|Type}}}
|-
! Topic: 
| {{{field|Topic}}}
|-
! Field: 
| {{{field|Field}}}
|}
{{{end template}}}

'''Free text:'''

{{{standard input|free text|rows=10}}}


{{{standard input|summary}}}

{{{standard input|minor edit}}} {{{standard input|watch}}}

{{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}}
</includeonly>

When I tried to include your additions, the form got a bit weird (that type should be below the ‘Project title’

<noinclude>
This is the "Project" form.
To create a page with this form, enter the page name below;
if a page with that name already exists, you will be sent to a form to edit that page.


{{#forminput:form=Project}}

</noinclude><includeonly>
<div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div>
{{{info |page name=P<unique number> }}} 
{{{for template|Project}}}
{| class="formtable"
| Project title: 
| {{{field |title }}}
| -
! Type: 
| {{{field|Type}}}
|-
! Topic: 
| {{{field|Topic}}}
|-
! Field: 
| {{{field|Field}}}
|}
{{{end template}}}

'''Free text:'''

{{{standard input|free text|rows=10}}}


{{{standard input|summary}}}

{{{standard input|minor edit}}} {{{standard input|watch}}}

{{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}}
</includeonly>

However, even with your additions, the form will still produce a wiki page with the name I define, e.g. https://???.com/wiki/czxc

The problem is that it’s asking me for a name before it lets me in the form

I would like it to have either a unique number as you said (or even better a combination of letters and numbers) or the PAGE ID, instead of the project title.

That’s because there’s a space between the pipe and hyphen in:

| {{{field |title }}}
| -
! Type: 

When I use the Form:Project you posted above, and go to Special:FormEdit/Project, it creates the pages at P2, P3, etc.

You don’t have to include the forminput field you’ve created there; you can use e.g. {{#formlink:form=Project|link text=New project}} instead.

1 Like

Thank you very much for your reply.

I took your advice, and now this is the code

<noinclude>
This is the "Project" form.
To create a page with this form, enter the page name below;
if a page with that name already exists, you will be sent to a form to edit that page.

{{#formlink:form=Project|link text=New project}} 

</noinclude><includeonly>
<div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div>
{{{info |page name=P<unique number> }}} 
{{{for template|Project}}}
{| class="formtable"
| Project title: 
| {{{field |title }}}
|-
! Type: 
| {{{field|Type}}}
|-
! Topic: 
| {{{field|Topic}}}
|-
! Field: 
| {{{field|Field}}}
|}
{{{end template}}}

'''Free text:'''

{{{standard input|free text|rows=10}}}


{{{standard input|summary}}}

{{{standard input|minor edit}}} {{{standard input|watch}}}

{{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}}
</includeonly>

It does indeed create the pages as P, P2 etc now, However:

  1. It sets the name of the page as the unique string it produces, rather than the Project title I set it to

  2. It does not give me an option to edit that page title even though it still has it in the wikitext of the page. e.g. this is the wikitext of the page in the picture

    {{Project
    |title=Test?
    |Type=experimental
    |Topic=adsfafsd
    |Field=asdf
    }}

Any ideas how to make the page inherit the page title (while keeping the url unique) and let users edit that title?

Thank you once again

You need to set the following in LocalSettings.php

$wgAllowDisplayTitle = true;
$wgRestrictDisplayTitle = false;

and then use this in your Template:Project:

{{DISPLAYTITLE: {{{title|}}} }}

That will set the displayed title of every project page to be the same as the title defined in the template. The Px will still be used in the URL.

1 Like

Thank you very much for your help, that works perfectly now!

1 Like