CodeIgniter Forums

Full Version: Controller not loading page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to create a new landing page template based on my home page. I copied my index.pgp template and renamed it landing3. I created copied my existing controller for landing pages, and called it details3. Here's the code from my details3 file:

PHP Code:
class Details3 extends CI_Controller {

 function 
__construct()
 {
 
parent::__construct();
 
 
$this->themes->set_theme('research');
 
$this->themes->set_template('landing3');
 
 } 
 
 function 
index($product)
 { 
 
 
$data['prodname'] = ucwords(str_replace('_'' '$product)); 
 
$data['keywords'] = $this->_keywords($product);
 
$data['descript'] = $this->_descriptions($product);
 
               $data['title'] = $this->_pagetitles($product);
 
$data['product'] = $product;
 
$data['view2'] = $this->_view_two($product);
 
//echo '<pre>'; print_r($data); echo '</pre>'; exit(); 
 
$this->themes->view('promote3/landingpages'$data);
 
 
 } 

You can see the template is set to landing3, which I just created. I then set the route to this:

PHP Code:
$route['details3/(:any)'] = "details3/index/$1"

When visiting my page at mysite.com/details3/product I get a blank page, nothing loads. I would at least expect the template to load but it does not. What am I doing wrong?
In your method:

Code:
 function index($product)

What is the default value of $product? 
For example:
Code:
function index($product="default_product_code")

I don't see how it can be set using the URL which you used to test this:

Quote:mysite.com/details3/product
Which does not contain a value for $1, so a default product value is needed.

This might not be the only problem but...
I didn't create any of this code, just copied form my existing templates and controllers, so I cannot comment on the logic of it too much. I am just poking through it myself. I have other landing pages working in this same manner, designed by another person a few years ago. I just copied the working code from the existing details and landing page files into details1, details2, details3 etc and same for the landing pages. I have successfully created details1 and details2 in the past and using details2/someproduct, but I cannot remember what I did to get it to work.

As for the "detals3/index/$1", isn't that saying: call detials3 controller, run the index method and use $1 as a parameter, $1 being the name of the product (details/SOMEPRODUCT)? I'm calling my other landing pages from details, details1, and details2 this way and it's working.
Ok, I was misinterpreting your URL. Sorry, I don't see anything else.

Am I correct in reading that you do get this to work for controllers:
details, details2 and details2?

Since it works (rerouting) using the other controllers, then I'd check the precise
spelling of the other route statements.

Have you tried different product names?
Did you try doing this?

PHP Code:
function __construct()
 {

 
$this->themes->set_theme('research');
 
$this->themes->set_template('landing3');

 
parent::__construct(); 
 } 
(02-17-2015, 09:31 PM)twpmarketing Wrote: [ -> ]Ok, I was misinterpreting your URL.  Sorry, I don't see anything else.

Am I correct in reading that you do get this to work for controllers:
details, details2 and details2?

Since it works (rerouting) using the other controllers, then I'd check the precise
spelling of the other route statements.

Have you tried different product names?


Yes, I have gotten this to work with details1, and details2, which are copies of the original details file. I did try different product names but none of them load anything.

(02-18-2015, 12:43 AM)Avenirer Wrote: [ -> ]Did you try doing this?



PHP Code:
function __construct()
 {

 
$this->themes->set_theme('research');
 
$this->themes->set_template('landing3');

 
parent::__construct(); 
 } 

Just tried moving  parent::__construct();  after the theme and template calls, but that didn't work. Besides, this is a copy of my existing details2 file, which is working with the  parent::__construct();  line before the theme and template calls.
Any other suggestions?
Wait a second... I see that you are extending CI_Controller. Where did you define the themes()? In the CI_Controller?
It extends CI_Controller but I do not know where CI_Controller is actually located, have never seen that in any of the site's files. So I do not know where I could check to see if the theme is defined there. And what would the theme definition look like? But like I said, I just copied the details2 controller, which is working, into the new details3 controller. So it should just work the way it is.
Go to your config folder and in config.php and make some changes to see error log, this should help identifying where problems are
$config['log_threshold'] = 4; //change it to 4 so you can see all errors

Run it again and open the error log under logs/log-yyyy-mm-dd.php

Good luck