Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8
This is the forum to discuss the Wrox book Professional CodeIgniter by Thomas Myer; ISBN: 9780470282458
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old July 3rd, 2009, 05:37 AM
Registered User
 
Join Date: Jul 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Controller Question

In the index funtion the code is .

function index() {

$data['title']="Welcome to Claudia's site";
.......
.......
}

How is it that $data['title'] becomes $title in the template view as you write ?

Thanks.
  #2 (permalink)  
Old July 6th, 2009, 06:09 PM
Wrox Author
 
Join Date: May 2008
Location: Austin, TX, USA.
Posts: 53
Thanks: 0
Thanked 5 Times in 5 Posts
Default sorry for the delay....

....was trying to get some projects out the door, but now i'm back!

$data['title'] in the controller becomes $title in the view via a simple process:

Right before you load the view, you have to load the vars stored in $data, like this:

PHP Code:
function index(){
  
$data['title']  = "This is my title....";
  
$data['other_stuff'] = "Other stuff....";

  
$this->load->vars($data);
  
$this->load->view('template');


After that, create a template.php view, and in that, you can use $title and $other_stuff, etc.
__________________
Thomas Myer
Author, Professional CodeIgniter
http://www.tripledogs.com


Similar Threads
Thread Thread Starter Forum Replies Last Post
testing a controller using rspec Manoah RoR Ruby on Rails 0 September 26th, 2008 04:02 AM
PHP Controller cyber_kaley20 Beginning PHP 0 July 8th, 2007 10:12 PM
controller to controller tigransh Spring 1 November 11th, 2006 12:48 AM
throwaway controller mmasters BOOK: Professional Java Development with the Spring Framework 0 June 27th, 2006 10:56 AM
Model View Controller gpartin33324 Java GUI 0 October 4th, 2004 04:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.