Interspire Product Knowledge Base

Would you like to...

Print this page Print this page

Email this page Email this page

Post a comment Post a comment

Subscribe me

Add to favorites Add to favorites

Remove Highlighting Remove Highlighting

Edit this Article

Export to PDF

User Opinions (2 votes)

50% thumbs up 50% thumbs down

How would you rate this answer?



Thank you for rating this answer.

How can I change URLs to be example.com/articles/article-title/idnumber-pagenumber.html ?

This code change is for IWP 4.5.x. It might also work on ArticleLive NX 2.0.x, but it is not guaranteed.

This guide will change your current URL structure from:

www.example.com/articles/{article-id-number}/{article-page-number}/{article-title}/Page{article-page-number}.html

to

www.example.com/articles/{article-title}/{article-id-number}-{article-page-number}.html

Open /admin/includes/classes/class.helper.php

Change the ArticleLink function from this:

function ArticleLink($ArticleId, $ArticleTitle, $ArticlePage = 1) {
    if ($GLOBALS['AL_CFG']['useids'] == 1) {
        $link = sprintf("%s/%s/%d/%d/", $GLOBALS["AL_CFG"]["siteURL"], GetLang('urlArticles'),
            $ArticleId, $ArticlePage);
    } else {
        $suffix = sprintf("%s/%s%d.html", AL_HELPER::_MakeArticleURLSafe($ArticleTitle), AL_HELPER::_MakeArticleURLSafe(GetLang('artPage')), $ArticlePage);

        $link = sprintf("%s/%s/%d/%d/%s", $GLOBALS["AL_CFG"]["siteURL"], GetLang('urlArticles'), $ArticleId, $ArticlePage, $suffix);
    }
    return $link;
}



to this:

function ArticleLink($ArticleId, $ArticleTitle, $ArticlePage = 1) {
    if ($GLOBALS['AL_CFG']['useids'] == 1) {
        $link = sprintf("%s/%s/%d/%d/", $GLOBALS["AL_CFG"]["siteURL"], GetLang('urlArticles'),
            $ArticleId, $ArticlePage);
    } else {
        $link = sprintf("%s/%s/%s/%d-%s.html", $GLOBALS["AL_CFG"]["siteURL"], GetLang('urlArticles'),  AL_HELPER::_MakeArticleURLSafe($ArticleTitle), $ArticleId, $ArticlePage);
    }
    return $link;
}


Now open up /includes/classes/class.article.php and find:

$this->_page = $this->Segments[2];
and remove it, or comment it out like:

// $this->_page = $this->Segments[2];

Then finally open up /includes/classes/class.content.php and find the GetIdFromURL() function and change it from:

function GetIdFromURL($SearchStr) {

    $this->LoadURISegments($SearchStr);
    if(isset($this->Segments[1])){
        $id = $this->Segments[1];
    }else{
        $id = 0;
    }

    if(isset($this->Segments[2])){
        $pagenum = $this->Segments[2];
    }else{
        $pagenum = 0;
    }

    if (!is_numeric($id)) {
        $id = 0;
    }

    if (isset($_REQUEST["ArticleId"])) {
        $id = (int)$_REQUEST["ArticleId"];

    }elseif (isset($_REQUEST["ContentId"])) {
        $id = (int)$_REQUEST["ContentId"];

    }elseif (isset($_REQUEST["BlogId"])){
        $id = $_REQUEST["BlogId"];

    }elseif (isset($_REQUEST["NewsId"])) {
        $id = $_REQUEST["NewsId"];
    }

    return $id;
}


and change it to:

function GetIdFromURL($SearchStr) {

    $this->LoadURISegments($SearchStr);
    if($SearchStr == GetLang('urlArticles')){
        if(isset($this->Segments[2])){
            $id_long = $this->Segments[2];
            $id_long = str_replace(".html", "", $id_long);
            $idBits = explode("-",$id_long);
            $id = $idBits[0];
            $this->_page = $idBits[1];

        }else{
            $pagenum = $id = 0;
        }

    }else{
        if(isset($this->Segments[1])){
            $id = $this->Segments[1];
        }else{
            $id = 0;
        }
    }

    if (!is_numeric($id)) {
        $id = 0;
    }

    if (isset($_REQUEST["ArticleId"])) {
        $id = (int)$_REQUEST["ArticleId"];

    }elseif (isset($_REQUEST["ContentId"])) {
        $id = (int)$_REQUEST["ContentId"];

    }elseif (isset($_REQUEST["BlogId"])){
        $id = $_REQUEST["BlogId"];

    }elseif (isset($_REQUEST["NewsId"])) {
        $id = $_REQUEST["NewsId"];
    }

    return $id;
}




Related Articles

No related articles were found.

Attachments

No attachments were found.

Powered by Interspire Knowledge Manager - World's #1 Best Selling FAQ and Knowledge Base Software