ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Duplicate Page URI - can't a unique one be auto-generated?

February 11, 2011 8:28am

Subscribe [1]
  • #1 / Feb 11, 2011 8:28am

    Nightshade

    22 posts

    I am entering entries with the same titles (they are events with the same names). When I click Publish I get the error “Duplicate Page URI”. I don’t want to have to manually add a random number on the end of the auto-generated Page URI each time.

    Is there a way for the auto-generated Page URI to be unique each time?

    It seems logical that the system should check whether the Page URI has already been used (like Wordpress)

  • #2 / Feb 11, 2011 9:15am

    Nightshade

    22 posts

    It seems this is not to do with the “URL Title” field on the Publish tab, but the “Page URL” field on the Structure tab, which defaults to blank.

    I will see if I can hack Structure to copy the “URL Title” field value

  • #3 / Feb 11, 2011 9:56am

    Nightshade

    22 posts

    Here’s my solution for Structure 1.3.0 (the bug may have been fixed in v2 but that costs $65 and v1 was free):

    in /system/extensions/ext.structure_ext.php line 773:

    Change:

    if (in_array($data['uri'], $uris)) {                    
    
                $errors[] = $LANG->line('duplicate_page_uri');
                
            }

    For:

    if (in_array($data['uri'], $uris)) {
                
                global $IN;
                
                $i = 1;
                
                while( in_array( ($IN->GBL('url_title', 'POST') . "-" . $i) , $uris) ){
                    $i++;
                }
                
                $data['uri'] = $IN->GBL('url_title', 'POST') . "-" . $i;
                
                
            }
  • #4 / Feb 11, 2011 12:57pm

    Ingmar

    29245 posts

    It seems logical that the system should check whether the Page URI has already been used

    It does for regular entries, but with the Pages module it assumes you have a certain structure in mind. Still might make for a good Feature Request, perhaps?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases