Tuesday, November 9, 2010

Page Title

From your home page observe the page title, it should be something like this: "CakePHP: the rapid development php framework: Users"

The first part of the title is defined in the default layout. The layout predefines the wrapper HTML code of every page. This file is located in /cake/libs/view/layouts/default.ctp and before editing it you should move it to /app/views/layouts/default.ctp

Next, edit the page and remove the following line:
<?php __('CakePHP: the rapid development php framework:'); ?>
Upload the file and test it and your home page title should just read "Users".

Now click on the username and the title will read "Scaffold :: View :: Users" While the default titles can be helpful, you will want to change them to reflect your site's method.

Edit /app/controllers/users_controller.php and for the first line in the index() method add the following:
$this->set("title_for_layout", 'Drug-ed.com : Drug Education and Medication Adherence');
Save the changes upload the file and test it at site root. This command will also work if you add it to /app/views/users/index.ctp, however, since you are modifying variables it is best practice to do it within the controller.

No comments:

Post a Comment