Welcome Guest, Not a member yet? Register   Sign In
Permalink / Clean URL question
#4

[eluser]Gavin Blair[/eluser]
Your articles can have a title ("My Article Title") and a nicename, like Wordpress does ("myarticletitle") It's just the title without caps or spaces. You could convert spaces and other characters to hyphens (-) too.

When creating the nicename, you'll want to check for duplicates so you can add the -2 if needed.

Code:
$this->db->select('nicename');
$this->db->where('nicename', $newnicename);
$query = $this->db->get('articles');
$duplicates = $query->num_rows();
if ($duplicates > 0) {
$duplicates += 1;
$newnicename = $newnicename . "-" . $duplicates;
}
$this->db->insert('articles', array( 'nicename' => $newnicename, 'title' => $newtitle, ... ));
Hope this helps!


Messages In This Thread
Permalink / Clean URL question - by El Forum - 06-10-2008, 09:33 PM
Permalink / Clean URL question - by El Forum - 06-10-2008, 11:53 PM
Permalink / Clean URL question - by El Forum - 06-11-2008, 01:05 AM
Permalink / Clean URL question - by El Forum - 06-11-2008, 07:14 AM
Permalink / Clean URL question - by El Forum - 06-11-2008, 07:15 AM
Permalink / Clean URL question - by El Forum - 06-11-2008, 09:55 AM
Permalink / Clean URL question - by El Forum - 06-11-2008, 10:04 PM



Theme © iAndrew 2016 - Forum software by © MyBB