Monday, January 31, 2011

Re: $html->image no show

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 <zijn.digi...@gmail.com> wrote:
> On Mon, Jan 31, 2011 at 8:27 AM, ugarch <ugarc...@gmail.com> 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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: app_controller not allowing inheritance into child controllers for Auth ?

On Mon, Jan 31, 2011 at 4:02 PM, OldWest <jason@jasonwydro.com> wrote:
> I have my UsersController which of course extends my app_controller.
>
> In my app_controller I have my $components defined as such:
>
> $components = array('Acl', 'Auth', 'Session', 'RequestHandler');
>
> When I try to access my users index view, I get an error (which means that
> the Auth component has not been activated in the controller).
>
> BUT
>
> If I place this line direct in my UsersController:
>
> $components = array('Acl', 'Auth', 'Session', 'RequestHandler');
>
> The page works as expected.
>
> My remote server has the latter issue. But my local dev environment seems to
> extend the $components from the app_controller just fine.
>
> Does anyone know why this is happening? My local server is running php5.3
> and my remote is running php5.2.

Does UsersController extend app_controller, or AppController? It
should be the latter. Also, if you have a beforeFilter method, make
sure it calls parent::beforeFilter() so the AppController method is
run.

--
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

Re: $html->image no show

On Mon, Jan 31, 2011 at 8:27 AM, ugarch <ugarch74@gmail.com> 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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Internationlization Doesn't Seem to Work.

Hello, I'm trying to get my application to use a different language
using cake's i18n. I believe I have my application set up properly.

core.php
Configure::write('Config.language', 'ger');

Posts Controller Flash message:
$this->Session->setFlash(__('You must be registered before you can ask
a question.', true), 'error');

app/locale/ger/LC_MESSAGES/default.po (created using i18n console
then poedit)
The translation should be:
Sie müssen registriert sein, bevor Sie eine Frage kann fragen.

But my application is not using the translated version from my .po
file. Its still using the english version.

Am I missing something here? Thanks for any help.

--
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

Re: Has anyone used Geonames without webservice?

I think it's difficult to download all the stuff in local and how do you maintain?

I think google map api is your best choice. What you can do is save the unique query( keyword and resolved lat,lon ) in database so that for popular places you don't always have to go to  web service
.

On Mon, Jan 31, 2011 at 12:32 PM, Dave Maharaj <me@davemaharaj.com> wrote:

Just wondering is anyone has used the geonames database with cake but with own database, not thru webservices?

 

I know it's a monster database in size but I do not like the idea of using a service that's not on my own server. If it goes down then it affects my site so just curious if anyone has implemented it?

 

I have the db setup and basic model / controller to test out queries, but my way takes much longer than the webservices version so just curious if anyone has had any success?

 

Thanks,

 

Dave

--
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

--
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

Re: AjaxHelper

How about setting up a new input box "tag" with "add" button and add tags to
hidden input so when save the post on submit it is available from control and don't need to use
any ajax but javascript in client side?


On Mon, Jan 31, 2011 at 1:28 PM, elias <elias.lecomte@gmail.com> wrote:
I tried searching for tutorials on the web, but I couldn't find any.
Maybe I am using the wrong keywords, but I hope someone here, could help me out.

I have a blog - like model, and a tag model, that is associated with it (hasMany).
So I can assign tags to new posts. But adding a new tag, makes me have to close the post, create the tag and then restart with the post.

So I would like to be able to add tags with the AjaxHelper, when in the new blog post.

Anyone who knows a good tutorial for this?

Thx

--
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

--
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

AjaxHelper

I tried searching for tutorials on the web, but I couldn't find any.
Maybe I am using the wrong keywords, but I hope someone here, could help me out.

I have a blog - like model, and a tag model, that is associated with it (hasMany).
So I can assign tags to new posts. But adding a new tag, makes me have to close the post, create the tag and then restart with the post.

So I would like to be able to add tags with the AjaxHelper, when in the new blog post.

Anyone who knows a good tutorial for this?

Thx

--
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

app_controller not allowing inheritance into child controllers for Auth ?

I have my UsersController which of course extends my app_controller.

In my app_controller I have my $components defined as such:

$components = array('Acl', 'Auth', 'Session', 'RequestHandler');

When I try to access my users index view, I get an error (which means that the Auth component has not been activated in the controller).

BUT

If I place this line direct in my UsersController:

$components = array('Acl', 'Auth', 'Session', 'RequestHandler');

The page works as expected.

My remote server has the latter issue. But my local dev environment seems to extend the $components from the app_controller just fine.

Does anyone know why this is happening? My local server is running php5.3 and my remote is running php5.2. 

--
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

Has anyone used Geonames without webservice?

Just wondering is anyone has used the geonames database with cake but with own database, not thru webservices?

 

I know it’s a monster database in size but I do not like the idea of using a service that’s not on my own server. If it goes down then it affects my site so just curious if anyone has implemented it?

 

I have the db setup and basic model / controller to test out queries, but my way takes much longer than the webservices version so just curious if anyone has had any success?

 

Thanks,

 

Dave

Re: Newbie file upload question

If your getting started with file uploads looking at existing code could help you get started - otherwise you should ask a more specific question :)

its simple so long as you don't use swfupload; here are some links

http://tv.cakephp.org/video/jasonwydro/2011/01/29/cakephp_1_3_-_meio_image_upload_resize_gallery_tutorial
https://github.com/webtechnick/CakePHP-FileUpload-Plugin
https://github.com/josegonzalez/uploadpack
http://www.jamesfairhurst.co.uk/posts/view/uploading_files_and_images_with_cakephp
http://bakery.cakephp.org/articles/webtechnick/2009/02/10/file-upload-component-w-automagic-model-optional

 - S



On 31 January 2011 20:00, Paul Wheatley <mr.paul.wheatley@hotmail.com> wrote:

Hi,
Very new to CakePHP and my first post here, I am loving Cake so far but have run up against a small hurdle.
Can anyone point me in the direction of instructions on creating a form with a file upload field? It's for a registration form where the user uploads normal stuff (name, address, etc...) and an image or logo of their company.
From what I've seen of Cake so far I think it should be simple enough but I can't work it out, can anyone help?
Paul

--
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

--
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

Re: Newbie file upload question

Hi there
This should be helpful:
http://cakebaker.42dh.com/2006/04/15/file-upload-with-cakephp/

thanks

On Jan 31, 12:00 pm, Paul Wheatley <mr.paul.wheat...@hotmail.com>
wrote:
> Hi,
> Very new to CakePHP and my first post here, I am loving Cake so far but have run up against a small hurdle.
> Can anyone point me in the direction of instructions on creating a form with a file upload field? It's for a registration form where the user uploads normal stuff (name, address, etc...) and an image or logo of their company.
> From what I've seen of Cake so far I think it should be simple enough but I can't work it out, can anyone help?
> Paul

--
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

Re: Please help me! almost got crazy...with Tree behavior..

He was getting errors when calling a Tree helper method. As the array of helpers was set up incorrectly ($actAs instead of $actsAs) the helper wasn't loaded, so the method failed.

On 31 Jan 2011, at 13:19, rahul jeevan wrote:

hi

wat is the actual problem

On Mon, Jan 31, 2011 at 11:15 AM, Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com> wrote:
He had $actAs instead of $actsAs, so the behaviour wasn't loading. It's a common mistake.
On 29 Jan 2011, at 11:59, satya prakash wrote:

YOU ARE CHECH IN MODEL QUERYES AND CHECK SYNTAX ; OR ' OR " . THESE SOULD BE CHECK

--
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


--
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



--
rahul

--
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

Newbie file upload question


Hi,
Very new to CakePHP and my first post here, I am loving Cake so far but have run up against a small hurdle.
Can anyone point me in the direction of instructions on creating a form with a file upload field? It's for a registration form where the user uploads normal stuff (name, address, etc...) and an image or logo of their company.
From what I've seen of Cake so far I think it should be simple enough but I can't work it out, can anyone help?
Paul

Re: Configuration

And to make it complete, my last update.. :).

You would want to put LoadModel inside the if that checks if the cache is still existing.
Otherwise it just adds overhead, and their is no point in using the cache.

This is the code:

<?php
class AppController extends Controller {
    function beforeFilter() {       
        $this->pfSettings = $this->getSettings();
        $this->fillLayout();   
    }
   
    function fillLayout()
    {
        $this->set('site_name', $this->pfSettings['name']);
        $this->set('site_title', $this->pfSettings['name']);
        $this->set('site_description', $this->pfSettings['description']);         
    }
   
    function getSettings()
    {       
        //check to see if they are in the cache.
        if (!$cachedSettings = Cache::read('settings')) {
            //load settings model
            $this->loadModel('Setting');
            //find all in the settings database
            if($settings = $this->Setting->find('all')) {
                $configurations = array();
                foreach ($settings as $setting):
                    $configurations[$setting['Setting']['key']] = $setting['Setting']['value'];
                endforeach;
                Cache::write('settings', $configurations);
                return $configurations;
            }
            else
            {
                //TODO: set error that settings failed
                exit();
            }
        } else {
            //return the cached settings.
            return $cachedSettings;
        }
    }
}

--
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

Re: Configuration

And for the cache to work, this would be the completed code :p.

<?php
class AppController extends Controller {
    function beforeFilter() {
        $this->loadModel('Setting');
        $this->pfSettings = $this->getSettings();
        $this->set('site_name', $this->pfSettings['name']);
    }
   
    function getSettings()
    {       
        //check to see if they are in the cache.
        if (!$cachedSettings = Cache::read('settings')) {
            //fetch the settings from the database.
            if($settings = $this->Setting->find('all')) {
                $configurations = array();
                foreach ($settings as $setting):
                    //$configurations = array_merge(array($setting['Setting']['key']=>$setting['Setting']['value']));
                    $configurations[$setting['Setting']['key']] = $setting['Setting']['value'];
                endforeach;
                Cache::write('settings', $configurations);
                return $configurations;
            }
            else
            {
                exit();
            }
        } else {
            //return the cached settings.
            return $cachedSettings;
        }
    }
}

--
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

Re: Is there any way to incldue all models automatically

This is probably the answer what you are looking for:

$this->loadModel('modelname');

Of course replace modelname with the model you want to load, (singular).

Just had to use it myself :).

--
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

Re: Configuration

It was easy.
I just had to use loadModel to make sure the Setting model is loaded, also in different controllers.

<?php
class AppController extends Controller {
    function beforeFilter() {
        $this->loadModel('Setting');
        $this->pfSettings = $this->getSettings();
        $this->set('site_name', $this->pfSettings['name']);
    }
   
    function getSettings()
    {       
        //check to see if they are in the cache.
        if (!$cachedSettings = Cache::read('settings', 'long')) {
            //fetch the settings from the database.
            if($settings = $this->Setting->find('all')) {
                $configurations = array();
                foreach ($settings as $setting):
                    //$configurations = array_merge(array($setting['Setting']['key']=>$setting['Setting']['value']));
                    $configurations[$setting['Setting']['key']] = $setting['Setting']['value'];
                endforeach;
                Cache::write('settings', $configurations);
                return $configurations;
            }
            else
            {
                exit();
            }
        } else {
            //return the cached settings.
            return $cachedSettings;
        }
    }
}

--
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

Re: Configuration

And I also see that I still have an error when visiting other controllers/models then settings :).
Let's see if I can fix it, then I will re update my code.

--
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

Re: Configuration

Hi,

Everyone, thanks a lot for all this information!

Given the fact that the id could change, I have changed tom's tutorial (thx!) a bit, making it able to function without the core.php editing and being more flexible. (When you add a new field in the database, it automatically get's added to the settings).

Before I show you what I have changed, I do have one more question. It seems to mee that the cache doesn't work. (Because a debug inside the block that checks if it's cached, get's always activated.)
Do you need to do configuring before caching works?
Anyway, I'll google this myself too.

This is what I have made from it:
<?php
class AppController extends Controller {
    function beforeFilter() {
        $this->pfSettings = $this->getSettings();
        $this->set('site_name', $this->pfSettings['name']);
        debug($this->pfSettings);
    }

   
    function getSettings()
    {
        //check to see if they are in the cache.
        if (!$cachedSettings = Cache::read('settings', 'long')) {
            //fetch the settings from the database.
            if($settings = $this->Setting->find('all')) {
               
                $configurations = array();
                foreach ($settings as $setting):
                    //$configurations = array_merge(array($setting['Setting']['key']=>$setting['Setting']['value']));
                    $configurations[$setting['Setting']['key']] = $setting['Setting']['value'];
                endforeach;
                Cache::write('settings', $configurations);
                return $configurations;
            }
            else
            {
                exit();
            }
        } else {
            //return the cached settings.
            return $cachedSettings;
        }
    }
}

The debug outputs:
Array (     [name] => WebsiteTite test.
 [description] => This is a litlle text about this photoboot photoblog website. )

--
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

Re: Configuration

On Sun, Jan 30, 2011 at 11:55 AM, tom <tb.22@live.co.uk> wrote:
> Create a database table with the correct fields, perhaps called
> 'Settings'.
>
> You can then create (or bake) a model and controller to go with the
> table.
>
> The controller only needs an edit action. The action should get the id
> for the model from the applications configuration, rather than a
> variable passed to it like normal. Here's what I mean:
>
> class SettingsController extends AppController {
>
>        var $name = 'Settings';
>
>        function admin_edit() {
>                if (empty($this->data)) {
>                        $this->data = $this->Setting->read(null,
> Configure::read('settingsId'));
>                } else {
>                        if ($this->Setting->save($this->data)) {
>                                Cache::delete('settings');
>                                $this->Session->setFlash('Settings saved.');
>                                $this->redirect('/');
>                        } else {
>                                $this->Session->setFlash('Settings could not be saved. Please try
> again.');
>                        }
>                }
>        }
> }
>
> Notice that Configure::read('settingsId') is used to provide the id of
> the row in the database.
>
> So in /config/core.php you could put:
>
> Configure::write('settingsId', 1);

The ID never changes? Are you using just a single row in the database?
Why not pass the $id as a param?

--
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

Re: need help

On Mon, Jan 31, 2011 at 7:37 AM, Amit Badkas <amit.sanisoft@gmail.com> wrote:
> Hi,
> By setting 'empty' to false won't display the empty option but you need to
> set an extra option having label as 'select state', right? For this, set
> 'empty' => 'select state' instead of false in the 4th argument of select().

Speaking of confusing documentation! Yeah, I got sidetracked somewhere
and gave the wrong advice. Sorry, andy!

--
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

Re: Select Box - Table or Tinyint?

Hi LipeDjow

This may be a noob question, but how do you use the array_source DataSource?

Can you provide an example usage for this scenario.

--
Kind Regards
 Stephen @ NinjaCoderMonkey

 www.ninjacodermonkey.co.uk


--
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

Re: Containable Query Slow - Am I doing it wrong?

Here is the model for Category:
var $hasAndBelongsToMany = array(
'Product' => array(
'className' => 'Product',
'joinTable' => 'categories_products',
'foreignKey' => 'category_id',
'associationForeignKey' => 'product_id'
)
);
var $belongsTo = array(
'Parent' => array(
'className' => 'Category',
'foreignKey' => 'parent_id'
)
);

Here is the model for Product:
var $hasMany = array(
'Variation' => array(
'className' => 'Variation',
'foreignKey' => 'product_id',
'dependent' => false,
)
);

I think it's pretty straightforward. There are 32 categories, 86
products and 115 variations. Looks like it's doing a database call for
each variation.

--
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

Re: redirecting post data from a form

Another alternative would be save the data you need in the other
controller to the session using the session component which makes the
data available anywhere. You could create a temporary session key,
store it there, then when you are done with it, delete the session
data.

On Jan 31, 5:42 am, ojonam <manojo10...@gmail.com> wrote:
> Hello all,
>
> I have a flow in which I have a general form (Form 1), which accepts
> different types of inputs (each of which is handled by a different
> controller). So when I get information from the form regarding the
> type of input, I would like to redirect to the corresponding
> controller (ControllerA). Form 1 also contains other information in
> the POST variable.
>
> I would like to know how I can redirect to the corresponding
> controller, along with the POST variables. The redirect function
> unfortunately does not allow to include POST variables ($this->data),
> and I am not interested in sending the data as named parameters or
> GET.
>
> I tried applying the solution athttp://stackoverflow.com/questions/1871592/how-to-make-cakephp-redire...
> (using the dispatch function), but the view does not render properly.
>
> How could I solve this problem?
>
> Cheers,
> ojonam

--
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

Re: SecondController extends FirstController extends AppController: not supported? --psybear

Yeah, if you want to have an indeterminate depth of nested controllers
(which is fine), and you want to use Cake's component merging stuff,
then as far as I can tell you'll have to implement your own version of
Controller::__mergeVars() in your AppController class.

- Jamie

On Jan 31, 6:24 am, psybear83 <psybea...@gmail.com> wrote:
> Hey everybody
>
> I'm refactoring an application with some controllers and wanted to
> "divide" them into a group X (that needs some components) and a group
> Y that needs some other components. My idea:
>
> class AppController {
>   var $components = array('Html', 'Form');
>
> }
>
> class XController extends AppController {
>   var $components = array('X1', 'X2');
>
> }
>
> class YController extends AppController {
>   var $components = array('Y1', 'Y2');
>
> }
>
> Now every other controller should inherit from XController or from
> YController like this:
>
> class SomeXController extends XController {
>   var $components = array('Bla');
>
> }
>
> I expected XController now to have loaded the following components:
> Html, Form, X1, X2, and Bla. But sadly it doesn't have all of them! It
> seems CakePHP doesn't allow controller inheritance over more than only
> 1 level. Is this true? Is there any known work-around?
>
> Thanks a lot for help
> Josh

--
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

Re: Containable Query Slow - Am I doing it wrong?

ok, thanks for this informations... :D
--
Lep pozdrav, Tilen Majerle



2011/1/31 Jeremy Burns | Class Outfit <jeremyburns@classoutfit.com>
AFAIK there is no problem using a fields key inside 'contain'. It's a good way of drawing back less data.
On 31 Jan 2011, at 17:33, Tilen Majerle wrote:

i think (i'm not sure), but in contain key you should not use 'fields', 'conditions' and so on keys, because this you should do when you make a model associations, so you should do just this

{{{

$this->Category->Behaviors->attach('Containable');
$tempCategories = $this->Category->find('all', array(
       'fields' => array('id','title','description','order'),
       'order' => array("Parent.title" => "asc","Category.order" => "asc"),
       'contain'=>array(
               'Parent' ,
               'Product' => array(
                  'Variation'
               )             
        )
));

}}}

but like i said....i'm NOT sure....


--
Lep pozdrav, Tilen Majerle



2011/1/31 TimG <tim@gurske.com>
Hey,
This code below works well but the query is really slow. It adds five
seconds more to the page request time. Am I doing something wrong or
is it just the way it is? Also, is there a way to do this with a
custom query and would it be any quicker? Thanks in advance!

$this->Category->Behaviors->attach('Containable');
$tempCategories = $this->Category->find('all', array(
       'fields' => array('id','title','description','order'),
       'order' => array("Parent.title" => "asc","Category.order" => "asc"),
       'contain'=>array(
               'Parent' => array('fields' => array('id','title','description')),
               'Product' => array('fields' => array('id','title','description'),
                       'conditions' => array('active'=>1),
                       'Variation' => array('fields' => array('id','title','price'))
))));

--
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


--
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

--
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

--
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

Re: Containable Query Slow - Am I doing it wrong?

AFAIK there is no problem using a fields key inside 'contain'. It's a good way of drawing back less data.

On 31 Jan 2011, at 17:33, Tilen Majerle wrote:

i think (i'm not sure), but in contain key you should not use 'fields', 'conditions' and so on keys, because this you should do when you make a model associations, so you should do just this

{{{

$this->Category->Behaviors->attach('Containable');
$tempCategories = $this->Category->find('all', array(
       'fields' => array('id','title','description','order'),
       'order' => array("Parent.title" => "asc","Category.order" => "asc"),
       'contain'=>array(
               'Parent' ,
               'Product' => array(
                  'Variation'
               )             
        )
));

}}}

but like i said....i'm NOT sure....


--
Lep pozdrav, Tilen Majerle



2011/1/31 TimG <tim@gurske.com>
Hey,
This code below works well but the query is really slow. It adds five
seconds more to the page request time. Am I doing something wrong or
is it just the way it is? Also, is there a way to do this with a
custom query and would it be any quicker? Thanks in advance!

$this->Category->Behaviors->attach('Containable');
$tempCategories = $this->Category->find('all', array(
       'fields' => array('id','title','description','order'),
       'order' => array("Parent.title" => "asc","Category.order" => "asc"),
       'contain'=>array(
               'Parent' => array('fields' => array('id','title','description')),
               'Product' => array('fields' => array('id','title','description'),
                       'conditions' => array('active'=>1),
                       'Variation' => array('fields' => array('id','title','price'))
))));

--
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


--
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