Monday, January 31, 2011

$html->image no show

Hello, (I am new in CakePHP)

I setup a cake project on my local. http://localhost/~Alejandro/Alvaro/
I'm running MacOs Snow Leopard.

I already set my Alejandro.conf:

DocumentRoot "/Users/Alejandro/Sites/"
<Directory "/Users/Alejandro/Sites/">
Options Indexes MultiViews FollowSymlinks
AllowOverride all
Order allow,deny
Allow from all
</Directory>

also changed the .htaccess in the project directory for /.htaccess,

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~Alejandro/Alvaro/
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

app/.htaccess,

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /~Alejandro/Alvaro/
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>


and app/webroot/htaccess,

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~Alejandro/Alvaro/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>

I did not make any changes in the app/webroot/index.php. However in
cake/config/paths.php I placed the

if (!defined('WEBROOT_DIR')) {
define('WEBROOT_DIR', 'app'.DS.'webroot');
}

Now ... everything is working well in the main root page
(controller=>"page", action=>''display', 'home'),
In the default.ctp I have a set of links like:

echo $html->link('Areas Comunes', array('controller' =>
'informations', 'action' => 'area'), array('class'=>'navigation',
'escape'=>false));

and also a banner div that displays images with respect to the current
page, and I do it like this:

<div id="banner">
<?php echo $banner ?>
</div>

The $banner is set in the controllers, so If we are in the main root
page, I set $ banner in pages/display in the following way:

App::import('Helper', 'Html');
$html = new HtmlHelper();
$banner = $html->image('ubicacion.jpg',
array('class'=>'banner','title'=>"Foo"));
$this->set(compact('banner'));

I do exactly the same for the informations/area but once I clicked in
a link in default.ctp like:

echo $html->link('Areas Comunes', array('controller' =>
'informations', 'action' => 'area'), array('class'=>'navigation',
'escape'=>false));

(HERE COMES THE PROBLEM) the image I set in banner is no show for
(informations/area).
However if in firebug I modify the image link from "img/banner.jpg" to
"../img/banner.jpg" WORKS!
Nevertheless the $banner for the main page (page/display) works fine
and displays the image.

<div id="banner">
<?php echo $banner ?>
</div>

I tried almost everything, but I don't know what I did not tried cause
I cannot make it work. I would really appreciate any help.

Thank you very much in advance!

A.

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: