Part of the EllisLab Network
   
 
SEO / Pass variable from controller through MYcontroller to view template
Posted: 26 August 2009 12:03 PM   [ Ignore ]  
Summer Student
Total Posts:  13
Joined  08-14-2009

Ok, so this is probably a trivial problem, but I don’t really know how to get it done. I want to assign meta tags to each of my controllers and/or the functions of those. My plan was, to include something link this in either the Constructor and/or the respective function(s):

$this->data = array(
    
'titletag'         => "Your title tag here",
    
'metadescription'     => "Your page's description here",
    
'metakeywords'         => "keywords, keywords, keywords",
    
'pagetitle'        => "Tampa Business Directory",
    
'content_view'         => null,
    
'content_data'        => ''
); 

For the views, I have a function view_template in MYController to include other template parts etc, so whenever I call a view it kinda looks like this:

$content $this->parser->parse('produkte/template', array('produkte' => $query), true);
$this->view_template($content); 

In the view_template function I can define a variable such as

$data['titletag''title tag is working'

and then call it in my actual template using

<?=$titletag;?> 

What won’t work is this

$data['titletag'$titletag

The question now is, how to pass the variable or rather all variables all the way through from the controller to the view_template function in MYcontroller on to the actual template/view.

If you have any other advice on how to do SEO with CI and make things a little easier, I am open for suggestions!

Thanks so much in advance!

Profile
 
 
Posted: 26 August 2009 12:13 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  13
Joined  08-14-2009

I forgot, it’s not in my code but I tried passing $data through as a parameter, when parsing the content or calling the view_template. That didn’t work for me.

Profile
 
 
Posted: 26 August 2009 06:48 PM   [ Ignore ]   [ # 2 ]  
Research Scientist
Avatar
RankRankRankRankRankRank
Total Posts:  5399
Joined  06-19-2009

Hi,

$data['titletag'$titletag;

try 
setting $titletag to a value ie$titletag "my title"

Enjoy
InsiteFX

 Signature 

Custom Designed Icons, eBook Covers Software Boxes. CD, DVD Etc. New iPhone® Tab Bar Icons and iPhone® Applications Icons.

STOP! Before posting your questions, remember the WWW Golden rule:
What did you try? What did you get? What did you expect to get?

Input -> Controller | Processing -> Model | Output -> View

Profile
 
 
Posted: 27 August 2009 05:30 AM   [ Ignore ]   [ # 3 ]  
Summer Student
Total Posts:  13
Joined  08-14-2009

That’s what I am trying to do. Just not in the MYController file but in the controller before that. It kind goes like this:

Controller (here I want to define title/meta variables e.g. $titletag=“my title”

|

MYController (here I have got the view_template function to call the template, here I want to call the variables from the controller to pass them on to the template e.g. $data[‘titletag’] = $titletag )

|

Template (here is where I want to actually include the variables e.g. <?=$titletag;?>)


EDIT: Just passing information from the view_template function in MYController to the template already works like this: $data[‘titletag’] = ‘my title’. My problem is the connection between the individual controllers and the view_template function in MYController.

Profile