Codeigniter dynamic text in language array

Wednesday, November 4, 2015

I am trying to set title, meta description and keywords dynamically using the language feature like below:



$lang['/contact_title'] = "Contact Us";
$lang['/contact_desc'] = "Description for contact us page";
$lang['/contact_keywords'] = "key, words";


and in header file I am using it like below:



<title><?echo $this->lang->line($_SERVER['PATH_INFO']."_title");?></title>
<meta name="description" content="<?echo $this->lang->line($_SERVER['PATH_INFO']."_desc");?>">


So far this is working great, but how I could make it work for dynamic titles? Regex was the first though that came in my mind, but unfortunately it doesn't work with language classes like it works for routing as I have already tried it.



Can anyone suggest me an idea/solution of how I could make it work with dynamic titles?

0 comments:

Post a Comment