Thank you very much for your response ... I liked the element idea but
my problem is that sometimes in the banner div i need to place images
and sometimes videos or a picture slider.
That is why I decided to set the $banner from the controller the way I
did. But my problem is more related to paths and links because when I
set $banner = $html->image('Foo.jpg'
array('class'=>'banner','title'=>"Foo")); from the
pages_controller.php it works fine. However when I set the $banner
from the informations_controller.php the image does not shows up. I
can see in the html source code the image but the path needs to be
changed from 'img/Foo.jpg' to '../img/Foo.jpg' ... Do you have an
idea, why do i need to change the image path to ../ so I can see the
picture?Also thank you very much for the .htaccess tips, have not try them yet but soon. A. On Jan 31, 4:38 pm, cricket <[email protected]> wrote: > On Mon, Jan 31, 2011 at 8:27 AM, ugarch <[email protected]> wrote: > > 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. > > I'm not sure I'm following all that, but a couple of points: > > As you have the ability to create the virtualhost config, you should > disable .htaccess and place the mod_rewrite stuff in the VHost config. > This will speed up requests. Set AllowOverride to None, and place > this: > > <IfModule mod_rewrite.c> > RewriteEngine on > RewriteBase /~Alejandro/Alvaro/ > RewriteRule ^$ app/webroot/ [L] > RewriteRule (.*) app/webroot/$1 [L] > </IfModule> > > ... inside the Directory block. > > Next, you have DocumentRoot "/Users/Alejandro/Sites/" but your > mod_rewrite rule points to "/~Alejandro/Alvaro/". I've never dealt > with setting up UserDir for Cake, so I'm not sure what to say about > this. But it looks wrong to me. > > The other thing is that you're importing HtmlHelper inside your > controller and creating the img tag there. This is unnecessary. You'd > be better off creating a banner.ctp element. In the controller action: > > $this->set('banner_img', 'ubicacion.jpg'); > > In the layout: > > $this->element('banner'); > > app/views/elements/banner.ctp: > > $html->image('img/banners/'.$banner_img, array('class'=>'banner', > 'title'=>"Foo")); > > You probably don't really need the 'class'=>'banner', either, as you > could wrap the img tag with <div id="banner"></div> and refer to it in > your stylesheet as #banner img. That's how I'd do it, anyway. -- 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 [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
