Re: Cake PHP to improve Joomla

2011-03-17 Thread Eddy
Hi unless whatever you need to develope absolutely needs to be a
component, why not install cake in a folder separate (or inside) from
you joomla installation, configure it to work from there and later
create a wrapper (which is a nice name for iframe ) in a content from
joomla and point that wrapper to the url of you cakephp installation.

I haven't tried this by myself but I can't see why it wouldn't work.

On Mar 17, 6:43 am, "Mariano C."  wrote:
> I need to develop some joomla component, I haven't time to learn
> joomla's MVC approch so I would use cakephp to develop this component.
> I've seen around there is a lot of way to do this. One of best way is
> to use cake itself as component as suggested 
> here:http://www.gigapromoters.com/blog/2007/02/13/finally-a-practical-solu...
>
> So I’ve downloaded Joomla 1.6.1 and cake 1.3.7.
> I’ve installed and configured Joomla. Working.
> Then extracted cakephp zip, renamed it as com_cake and putted it under
> joomla’s components directory.
>
> Then I renamed index.php as cakephp.php, added to com_cake the file
> cake.php and cake.html.php, configured cake’s database config file as
> explained in the link above.
>
> When I try to reach:http://localhost/joomla/index.php?option=com_cake
> I have:
>
> Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\joomla
> \components\com_cake\cake.php on line 13
>
> and line 13 is:
> $joomla_path=dirname(dirname(dirname(__FILE__)));
>
> Anybody has try a solution like this?

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: How to validate multiple fields with the same name?

2011-03-15 Thread Eddy
Thanks, I can't believe the solution was so simple! With saveAll() the
data gets validated just as I needed. Thanks!!

The only changes I had to do were in the controller
/// IN THE CONTROLLER function listProducts()
data) )
{
$this->Product->set($this->data);
if( $this->Product->saveAll($this->data) )
{
 $this->Session->setFlash('Product Saved.');
 $this->redirect(array('action' => 'listProducts'));
}
else
{
  $this->Session->setFlash('Error saving product!');
  $this->redirect(array('action' => 'listProducts'));
}
}
?>

On Mar 10, 10:35 am, Sam Bernard  wrote:
> You *should* be able to do this with "saveAll". saveAll will validate your
> records and then try to save all the records in a single transaction, so you
> don't have to validate first and then perform a transaction.
>
> If for some reason you wanted to validate separately- just do:
> $this-> Product->saveAll($this->data['Product'], array('validate' =>
> 'only'))
> to just perform validation on your records
>
> http://book.cakephp.org/view/1031/Saving-Your-Data

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


How to validate multiple fields with the same name?

2011-03-09 Thread Eddy
Hello people. I been trying to validate a form with several product
names but haven't been succesful. The last two days were spent
searching for a way to do this but with no results either.
The thing is I have a view with a form with a single field:
product_name and the necesary code in the controller to recieve $this-
>data, and save if the data passed validation, and the model with the
validation method to check if the name is unique, not too short or too
long and not empty.

// IN THE VIEW list_products.ctp
Form->create('Product');

echo $this->Form->input('Product.product_name', array('label'
=> 'Product Name'));

echo $this->Form->input('Product.provider_id', array('type' =>
'hidden', 'value' => 'whatever number' ));

echo $this->Form->end('Save Product');
?>

/// IN THE CONTROLLER function listProducts()
data) )

{

$this->Product->set($this->data);



if( $this->Product->validates($this->data) )

{

$this->Product->begin();

if( $this->Product->save($this->data['Product']) )

{

$this->Product->commit();

$this->Session->setFlash('Product Saved.');

$this->redirect(array('action' => 'listProducts'));

}

else

{

$this->Product->rollback();

$this->Session->setFlash('Error saving product!');

$this->redirect(array('action' => 'listProducts'));

}

}
}
?>

/// IN THE MODEL
 array(

'minLength'=>array(

'rule' => array('minLength', 5),

'message' => 'Too short',

),

'maxLength'=>array(

'rule' => array('maxLength', 200),

'message' => 'Too long',

),

'notEmpty' => array(

'rule' => 'notEmpty',

'message' => 'You can't leave this 
empty',

),

'isUnique' => array(

'rule'  => 'isUnique',

'message' => 'Name not unique',

),

),

);

}

?>

But now I have been trying to change this view so I can type 1 to 5
product names at once.
So my view now looks like this (which I found how to do it in the
cookbook):
Form->create('Product');

echo $this->Form->input('Product.0.product_name', array('label' =>
'Product Name'));

echo $this->Form->input('Product.1.product_name', array('label' =>
'Product Name'));

echo $this->Form->input('Product.2.product_name', array('label' =>
'Product Name'));

echo $this->Form->input('Product.3.product_name', array('label' =>
'Product Name'));

echo $this->Form->input('Product.4.product_name', array('label' =>
'Product Name'));


echo $this->Form->input('Product.provider_id', array('type' =>
'hidden', 'value' => 'whatever number' ));

echo $this->Form->end('Save');

?>
This way I have $this->data looking like this:
Array
(
[Product] => Array
(
[0] => Array
(
[product_name] => name 1
)

[1] => Array
(
[product_name] => name 2
)

[2] => Array
(
[product_name] => name 3
)

[3] => Array
(
[product_name] => name 4
)

[4] => Array
(
[product_name] => name 5
)

[provider_id] => whatever number
)
)


Now, the problem is that I can't figure out how to validate $this-
>data[Product]. The model always return as if the validation was
correct and the controller proceeds to save. I know that I have to
change the controller to saveall() instead of saving a single field
but still, no matter how I set the data before validation it doesn't
validate.

Please 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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


$paginator->hasNext bug?

2009-08-18 Thread Eddy Josafat

I use $paginator->hasNext() function in order to decide if application
shows $paginator->next link. It works properly, but when I set the
limit to 0 (showing all results in one page), hasNext returns true.

Is this a cakephp bug? Anyone has seen this issue?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: 500 errors and mod_rerwite

2009-08-06 Thread Eddy Josafat

If you aren't planning to host another app in your free space, I
recommend put app and cake directorys inside your
theotest.awardspace.biz folder for simplicity.

Ask technical support if .htaccess files are allowed in your free
hosting plans. If it's, then try to put this line in all the .htaccess
files:

RewriteBase /

(below the line )

That solved a similar problem in 1and1 hosting.


On Aug 5, 10:32 am, Theo  wrote:
> Hi,
>
> I'm new to cakePHP after becoming disenfranchised with code igniter. I
> followed the blog tutorial and have decided to put it online on a free
> hosting (http://theotest.awardspace.biz/) as if it where a production
> site ( in experience this is very different form doing on your own
> LAMP set up).
>
> The directory structure I'm forced/ would like to used is
>
> /home/www/ (my root)
>      app
>      cake
>      theotest.awardspace.biz/ (my web root)
>
> as I understand this should be perfectly acceptable (and allow me to
> share my cake across other sites).
>
> I've modified theotest.awardspace.biz/index.php to:
>
>         if (!defined('ROOT')) {
>                 define('ROOT', DS.'home'.DS.'www');
>         }
> /**
>  * The actual directory name for the "app".
>  *
>  */
>         if (!defined('APP_DIR')) {
>                 define('APP_DIR', 'app');
>         }
> /**
>  * The absolute path to the "cake" directory, WITHOUT a trailing DS.
>  *
>  */
>         if (!defined('CAKE_CORE_INCLUDE_PATH')) {
>                 define('CAKE_CORE_INCLUDE_PATH', DS.'home'.DS.'www');
>         }
>
> When viewing the site I get the summery page looking good with all the
> styles (http://theotest.awardspace.biz) but when I click a link I get,
>
> "Internal Server Error
>
> The server encountered an internal error or misconfiguration and was
> unable to complete your request.
>
> Please contact the server administrator, [no address given] and inform
> them of the time the error occurred, and anything you might have done
> that may have caused the error.
>
> More information about this error may be available in the server error
> log.
>
> Additionally, a 500 Internal Server Error error was encountered while
> trying to use an ErrorDocument to handle the request."
>
> I understand this could be some thing to do with mod_rewrite and
> my .htaccess files and I've tryed alot of things but with no luck.
>
> Thanks in advance.
>
> Theo.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Modificar html del mensaje de contraseña incorrecta en el componente Auth.

2009-08-06 Thread Eddy Josafat

Ya lo resolví,

$this->Auth->authError = 'Debe entrar en el sistema con una
contraseña.';

debe ir en el beforeFilter del resto de los controladores que
requieran autentificación, no en el de los usuarios.

On Jul 16, 4:20 pm, Eddy Josafat  wrote:
> Hola;
>
> Estoy intentando modificar el html que se genera automáticamente en el
> mensaje de contraseña incorrecta del componente Auth.
>
> El texto en si lo he modificado sin problemas tal como se comenta en
> la documentación:
>
> function beforeFilter() {
>                 $this->Auth->loginError = 'Su contraseña es incorrecta.';
>                 $this->Auth->authError = 'Debe entrar en el sistema con una
> contraseña.';
>         }
>
> Lo que no veo es la manera de decirle que html me genera, o mejor aun,
> que solo me salga el texto que ya me encargo yo en la vista de poner
> las etiquetas adecuadas.
>
> He buscado en los foros en inglés y por aquí pero no he encontrado
> nada.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: setFlash and redirect problem

2009-08-06 Thread Eddy Josafat

Thanks for advice. It was a typo: notificación instead of
notificacion. Sorry for wasting your time!

On Jul 30, 5:12 pm, "Dr. Loboto"  wrote:
> Error before redirect causes "blank page". Turn debug on and look at
> this error.
>
> On Jul 29, 10:29 pm, Eddy Josafat  wrote:
>
>
>
> > I have same problem and I don't use any translation.
>
> > $this->Session->setFlash('Contraseña modificada', 'notificación');
> > $this->redirect(array('controller' => 'gestion', 'action' =>
> > 'display', 'inicio'));
>
> > I get a blank page and no redirect with previous code. If I comment
> > the line that sets the flash message it works fine.
>
> > In another place of my app, if I create a new record, flash + redirect
> > works perfectly:
>
> > function nueva() {
> >                 if (!empty($this->data)) {
> >                         // Guardar fichero y almacenar url si se ha subido 
> > una imagen
> >                         $url = 
> > $this->_url_uploaded_file($this->data['Document']
> > ['submittedfile']);
> >                         if ($url) {
> >                                         
> > $this->data['Noticia']['url_imagen'] = $url;
> >                         } // $url
> >                         if ($this->Noticia->save($this->data)) {
> >                                 $this->Session->setFlash('Noticia guardada 
> > con éxito',
> > 'notificacion');
> >                                 $this->redirect(array('action' => 
> > 'listado'));
> >                         } else {
> >                                 $this->Session->setFlash('No ha podido 
> > almacenarse la noticia',
> > 'error');
> >                         } //   $this->Documento->save($this->data)
> >                 } // !empty($this->data)
> >         }
>
> > but when I'm doing editing an existing record:
>
> > function editar($id = null) {
> >                 $this->Noticia->id = $id;
> >                 if (empty($this->data)) {
> >                         $this->data = $this->Noticia->read();
> >                 } else {
> >                         $url = 
> > $this->_url_uploaded_file($this->data['Document']
> > ['submittedfile']);
> >                         if ($url) {
> >                                 // Borrar el anterior
> >                                         $noticia = $this->Noticia->read();
> >                                         if ( 
> > $noticia['Noticia']['url_imagen'] != $url ) {
> >                                                 
> > @unlink($noticia['Noticia']['url_imagen']);
> >                                         }
> >                                         
> > $this->data['Noticia']['url_imagen'] = $url;
> >                         }
> >                         if ($this->Noticia->save($this->data)) {
> >                                 $this->Session->setFlash('Noticia 
> > modificada', 'notificación');
> >                                 $this->redirect(array('action' => 
> > 'listado'));
> >                         } else {
> >                                 $this->Session->setFlash('No ha podido 
> > almacenarse la noticia',
> > 'error');
> >                         }
> >                 }
> >         }
>
> > flash + redirect causes a blank page.
>
> > What's the matter aobut flash messages and redirects?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: setFlash and redirect problem

2009-07-29 Thread Eddy Josafat

I have same problem and I don't use any translation.

$this->Session->setFlash('Contraseña modificada', 'notificación');
$this->redirect(array('controller' => 'gestion', 'action' =>
'display', 'inicio'));

I get a blank page and no redirect with previous code. If I comment
the line that sets the flash message it works fine.

In another place of my app, if I create a new record, flash + redirect
works perfectly:

function nueva() {
if (!empty($this->data)) {
// Guardar fichero y almacenar url si se ha subido una 
imagen
$url = $this->_url_uploaded_file($this->data['Document']
['submittedfile']);
if ($url) {
$this->data['Noticia']['url_imagen'] = 
$url;
} // $url
if ($this->Noticia->save($this->data)) {
$this->Session->setFlash('Noticia guardada con 
éxito',
'notificacion');
$this->redirect(array('action' => 'listado'));
} else {
$this->Session->setFlash('No ha podido 
almacenarse la noticia',
'error');
} //   $this->Documento->save($this->data)
} // !empty($this->data)
}


but when I'm doing editing an existing record:

function editar($id = null) {
$this->Noticia->id = $id;
if (empty($this->data)) {
$this->data = $this->Noticia->read();
} else {
$url = $this->_url_uploaded_file($this->data['Document']
['submittedfile']);
if ($url) {
// Borrar el anterior
$noticia = $this->Noticia->read();
if ( $noticia['Noticia']['url_imagen'] 
!= $url ) {

@unlink($noticia['Noticia']['url_imagen']);
}
$this->data['Noticia']['url_imagen'] = 
$url;
}
if ($this->Noticia->save($this->data)) {
$this->Session->setFlash('Noticia modificada', 
'notificación');
$this->redirect(array('action' => 'listado'));
} else {
$this->Session->setFlash('No ha podido 
almacenarse la noticia',
'error');
}
}
}

flash + redirect causes a blank page.

What's the matter aobut flash messages and redirects?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Modificar html del mensaje de contraseña incorrecta en el componente Auth.

2009-07-16 Thread Eddy Josafat

Hola;

Estoy intentando modificar el html que se genera automáticamente en el
mensaje de contraseña incorrecta del componente Auth.

El texto en si lo he modificado sin problemas tal como se comenta en
la documentación:

function beforeFilter() {
$this->Auth->loginError = 'Su contraseña es incorrecta.';
$this->Auth->authError = 'Debe entrar en el sistema con una
contraseña.';
}


Lo que no veo es la manera de decirle que html me genera, o mejor aun,
que solo me salga el texto que ya me encargo yo en la vista de poner
las etiquetas adecuadas.

He buscado en los foros en inglés y por aquí pero no he encontrado
nada.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---