⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

change page title



sachin vairagi
  • profile picture
  • Member

Posted 21 March 2013 - 14:00 PM

Hello,

 

is there any way to dynamically change page title?


victor
  • profile picture
  • Member

Posted 22 March 2013 - 08:12 AM

can you explain in more detail what do you want?


sachin vairagi
  • profile picture
  • Member

Posted 22 March 2013 - 10:44 AM

suppose i have 4 menus -

1.users

2.admin

3.distributor

4.retailer

 

when i click on users, it should show users in browser's tab, when i click on admin it should show admin and so on.


victor
  • profile picture
  • Member

Posted 22 March 2013 - 10:52 AM

for example

 

you have the links like this :

 localhost/controller/users.

localhost/controller/admin and others

 

change (or add) the "title" tag in the head of html document

<title><?=$this->uri->sement(2)?></title>


meyercr
  • profile picture
  • Member

Posted 23 March 2013 - 01:12 AM

Alternately, use Loader  method vars($array)  to add 'variables' into the final rendering of your template

 

in template use:

 

<head>

. . .

<?php if( isset($html_title) && $html_title != '' ){
     echo '<title>' . $html_title . '</title>';
} ?>

. . .

</head>

 

in your controller

 

$html_title ="This is the title I want";

 

change the output of your controller to add

 

$this->load->vars( array( 'html_title' => $html_title) );     // <- This puts $html_title into the context for the view() below

$this->load->view('template', $output);

 

 

 


victor
  • profile picture
  • Member

Posted 23 March 2013 - 06:44 AM

But I keep this data in a database...