slaeya Posted July 6, 2010 Share Posted July 6, 2010 Hi All, I know this has probably been asked a million and one times but when I searched the forums I didn't quite find what I was looking for (I'm not saying its not there) So.... Obviously I'm trying to get the <title> to populate. I have an SQL Database I am attempting to draw the information form. template.php <title>Fox Photography - <? echo $maintitle; ?></title> now for the controller home.php (I'm aware I can set the index page manually as it is not a dynamic page however if I can get this one sorted then I will be able to fix the rest in home.php (function pages)) I have also removed ALLLL my failed attempts at getting this to work so this is just base code without defining the variable $maintitle home.php function index() { $page_sefurl='home'; $table= 'pages'; $where= $page_sefurl; $query=$this->common_model->getComboxpages($table,$where); foreach($query->result() as $rows) { $array['page_name'] = $rows->page_name ; $array['page_metakeyword'] = $rows->page_metakeyword ; $array['page_metadescription'] = $rows->page_metadescription; $array['page_content'] = $rows->page_content; $array['page_sefurl'] = $rows->page_sefurl; $data['contents'] = $this->load->view('user/pages',$array,true); } $this->load->view('user/template' , $data); } function pages($page_sefurl,$client_login='') { if ($page_sefurl=='client-login') { $page_sefurl=$client_login; } $where="page_sefurl='".$page_sefurl."'"; $page_id =$this->common_model->getSingleValue('pages',$where,'page_id'); $table= 'pages'; $where= $page_sefurl; $query=$this->common_model->getComboxpages($table,$where); if($query->num_rows()>0) { foreach($query->result() as $rows) { $array['page_name'] = $rows->page_name ; $array['page_metakeyword'] = $rows->page_metakeyword ; $array['page_metadescription'] = $rows->page_metadescription; $array['page_content'] = $rows->page_content; $array['page_sefurl'] = $rows->page_sefurl; $data['contents'] = $this->load->view('user/pages',$array,true); } $this->load->view('user/template' , $data); } else { header("Location: ".base_url()."home/index"); } } I'm more than happy to just be given a link to an article to read as I don't expect others to just write the code for me. I'd rather learn than have someone fixing my "stuffups" all the time. Cheers Dave Link to comment https://forums.phpfreaks.com/topic/206854--/ Share on other sites More sharing options...
shortysbest Posted July 6, 2010 Share Posted July 6, 2010 The way i do mine, (im sure it's not the best by any means lol, but hey it works for me) is I take the name of the page, ie. Home, and i call it to the title My url would look like this: www.mysite.com/index.php?node=home $page = $_GET['node']; // so that would in this case be "home" <title><?php print ucwords($page)?> - My Website</title> // so this would be <title>Home - My Website</title> And then i use if and else, and or str_replace if i need to edit what i want in the title vs whats in the url. such as add a space, remove a space, remove an s, remove a _ or whatever it may be. sorry if this doesn't make much sense, it's 5am questions? ask please Link to comment https://forums.phpfreaks.com/topic/206854--/#findComment-1081771 Share on other sites More sharing options...
slaeya Posted July 6, 2010 Author Share Posted July 6, 2010 Shortysbest, Thanks for your reply, yes this does make complete sense. To my understanding the the php app is designed inhibits the use of ...../index.php?node=home I have tried they way you mentioned on my own PHP site previously and that seems to work fine. I just don't want to mess a friends site up. Cheers, Dave Link to comment https://forums.phpfreaks.com/topic/206854--/#findComment-1081776 Share on other sites More sharing options...
shortysbest Posted July 6, 2010 Share Posted July 6, 2010 Shortysbest, Thanks for your reply, yes this does make complete sense. To my understanding the the php app is designed inhibits the use of ...../index.php?node=home I have tried they way you mentioned on my own PHP site previously and that seems to work fine. I just don't want to mess a friends site up. Cheers, Dave No problem. Always nice to not mess up a friends' site Link to comment https://forums.phpfreaks.com/topic/206854--/#findComment-1081778 Share on other sites More sharing options...
slaeya Posted July 6, 2010 Author Share Posted July 6, 2010 Any other suggestions please? Link to comment https://forums.phpfreaks.com/topic/206854--/#findComment-1082185 Share on other sites More sharing options...
shortysbest Posted July 6, 2010 Share Posted July 6, 2010 Have you got any questions about it? Link to comment https://forums.phpfreaks.com/topic/206854--/#findComment-1082189 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.