First though, a word about images. Static image files for the site should go into the directory
/app/webroot/img/
as this directory allows direct access to the images without processing through a controller and when using the HTML helper (see below) you don't have to remember the beginning path to the image.
The site "favicon.ico" file should go in the
/app/webroot/
directory. There is a default file already there, so when you have an image for your site simply replace it.
Edit
/app/views/layouts/default.ctp
Inside the "header" div at the top remove the line beginning with "<h1>" and add the following:
<div class="logo"><?php echo $this->Html->link($this->Html->image('drug-ed-logo.png', array("alt" => "Drug-Ed.com")), Router::url('/'), array('escape' => false)); ?></div>The Html Helper is included in CakePHP to make creating links and other Html elements easier to code dynamically. The default format for using a helper is with
$this->HelperName
. Observe in the above code that an image element is contained within an link element. Since the image is stored within the /app/webroot/img/
directory as mentioned above, the path to the image is not required since the helper automatically includes it.
If your Html helper link includes html entities, such as the above image, by default the code is escaped out. To turn that feature off and allow the html in the title to be displayed properly add the
options
array to the link
function as above.
Save and upload the file then browse to site root to observe the changes.
No comments:
Post a Comment