In my model I have this function that defines the format of the url:
public function url_format_category($category, $lang_domin) {
if (lang('abbr') == 'en_US')
$lang_domin = 'en/';
else if (lang('abbr') == 'es_US')
$lang_domin = 'es/';
if (is_array($category))
$category = (object) $category;
if($category->title != '') {
$return = strtolower(url_title($category->title)).'-cmdo-'.$category->id;
}else{
$return = 'cursos-de-marketing-digital-online-'.$category->id;
}
return $return;
}
And in Controller I have the function that verifies if the url is right and redirects if it is wrong:
if($this->uri->uri_string != $this->learn->url_format_category($data['category'], $lang_domin)) {
redirect($this->learn->url_format_category($data['category'], $lang_domin),'location','301');
exit;
}
But now I have to do the same thing with a url that does not contain a Model, so I wanted to know if I can create these two functions on the Controller (together or separately) and how I could do that. Is it possible?
Note: I'm using CodeIgniter.