Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7937407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:31:11+00:00 2026-06-03T22:31:11+00:00

I am trying to create a Content Management System using Codeigniter. I have a

  • 0

I am trying to create a Content Management System using Codeigniter. I have a page where I display a list of article titles. When any user click on any of the article titles it will take the user to the details of that article in a separate page.

I am displaying the article title list using the following code:

 <a href="<?php echo base_url(); ?>article/<?php echo $row['article_id']; ?>">
 <?php echo $row['article_title']; ?></a>

When any user click on the above link it takes the article_id and go to the following controller

Controller:

function index($id){

   $this->load->model('mod_articles');
    $data['records']=$this->mod_articles->list_articles($id);
    $this->load->view('view_article',$data);
}

Model :

  function list_articles($id)
    {   
        $this->db->select('*');
        $this->db->from('article');
        $this->db->where('article_id', $id); 
        $query = $this->db->get();
        return $query->row_array();

    }  

Now when I display the result, in the browser’s address bar the link looks like this-

  localhost/cms/article/1         //<< here localhost/cms/ is my base_url

According to this website , an example of good SEO friendly URL is http://www.mysite.com/joomla-seo-tips .

Now my question is how to make my URL look like localhost/cms/article/my-article-title instead of showing the id of the article at the end of link?

To acheive this should I query for my article titles instead of article ids or there are some better ways to do that?

Please share your ideas on this.

Thanks in Advance 🙂

Edit

So, before saving my content should I run following code get the $article_slug and then save it?

function create_slug($string){
$slug=preg_replace('/[^A-Za-z0-9-]+/', '-', $string);
return $slug;
}

$article_slug= create_slug('My Name ');   // as you suggested I will create a new column for this
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T22:31:12+00:00Added an answer on June 3, 2026 at 10:31 pm

    When you save the record, give it a URL slug by running url_title() on the title (this should be a unique column, make sure to check for duplicate entries when saving).

    url_title("My page title!") should return something like my-page-title, see the url helper. I usually run strtolower on slugs as well, looks like CI allows caps.

    When you query for the content, get it by slug, something like:

    $this->db->where('slug', $this->uri->segment(1))->get('articles'); 
    

    And of course use the slug for your links instead of ids.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a content management system where the user can create multiple sites
I am trying to create a content management system with SEO friendly URLs ..
I am currently trying to create a content uploading system and although there are
I am trying to create a grid like system with div's with content floated
I am trying to create a site using the maven-site-plugin. it uses the content
At the moment I am trying to create a setup where page content is
I'm trying to create flowing content using CSS columns, but I'm running into the
I have been trying to create a new content type for Plone based on
Currently trying to create an XML system using Ogre and the STL. As a
I'm trying to create content via a small C# desktop app, and have it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.