Monday, November 30, 2009

Pagination - Wrong URL's (/page:x/page:x/....)

Somehow the url's for my paginations looks like:

.../articles/page:2/page:2
.../articles/page:3/page:3
....

After I click on next page, they looks like:

.../articles/page:2/page:2/page:2
.../articles/page:3/page:3/page:3
....


My controller:

function articles ($id = null)
{
$this->paginate['Article'] = array
(
'conditions' => array ('Article.id' => $id),
'contain' => array
(
'Tag',
'User' => array
(
'fields' => array ('id', 'use_status_id', 'firstname',
'lastname', 'avatar'),
'UseStatus'
)
),
'order' => array ('Article.created DESC'),
'limit' => 10,
'page' => 1
);

$this->set ('results', $this->paginate ('Article'));
}


The view:

....
....
<?=$paginator->numbers ()?>

How can I fix it? I'm using CakePHP 1.2.5


Thank a lot for any hint!

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

ajax->submit and form validation

Hi all,

i am new to cakephp. i have created an application have two
functionality on single form.
i am using cake 1.2.5.

here is my application:

i have customer form. this form contains bellow fields,
1. input box customer name
2. input box customer account no and form for insterting address
3. form for addresses
inputbox address
inputbox city
inputbox state
$ajax->submit()
4. final submit button to save customer form.

now my problem is that i have implemented ajax save functionality but
i m trying to implemented validation on addresses form.

i have created two model form this . customer.php, address.php
i have created only one controller customer_controller.php.into that i
have created one function to handle ajax add,
add_addresses(). and created one final for this evenet.
add_address.ctp.

please tell me what should i do to enable validation address form.

Thanks & Regards

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

Re: managing the "missing argument" errors

Hi again,

El 30/11/2009, a las 9:35, Ernesto escribió:

> too many ifs in my controllers.

It think this is unavoidable.

Setting the argument with a default value of null avoid the PHP error
of "missing argument",

function edit($id = null) {...}

but you need to give some response to the situation.

Only the proper action "knows" how many arguments are mandatory, so
you need to check if they are set and valid. The default value
approach "normalizes" the arguments for the validation check. (Your
approach takes two steps: check argument's existence and validation).

You could ignore the argument fault and delegate to the view to deal
with the absence of data to edit/show:

In the controller simply let the action try to find the item with the
id of null. The result will be false, no ifs needed. Then, in the view:

if (!$item) {
echo 'No valid data to edit/show':
} else {...}

If this logic must go in the controller or in the view depends on
several factors.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

Re: managing the "missing argument" errors

similar to my approach.

too many ifs in my controllers.

On 30 Nov, 09:20, Fran Iglesias <cakephpi...@gmail.com> wrote:
> Hi,
>
> El 30/11/2009, a las 9:16, Ernesto escribió:
>
> > but that's unconfortable...
>
> My approach:
>
> in controller...
>
> function edit($id = null) {
>         if (!$id) {
>                 $this->Session->setFlash('INvalid URL');
>                 $this->redirect (array('action' => 'index');
>         }
>
>         // Code, code, code
>
>
>
> }

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

Re: managing the "missing argument" errors

Hi,

El 30/11/2009, a las 9:16, Ernesto escribió:

> but that's unconfortable...

My approach:

in controller...

function edit($id = null) {
if (!$id) {
$this->Session->setFlash('INvalid URL');
$this->redirect (array('action' => 'index');
}

// Code, code, code
}

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

managing the "missing argument" errors

hello.

is there any clever (simple?) way to manage the "missing argument"
error?

for example:

if i call directly from the browser's address bar an url like this

"http://localhost/cake/myapp/myctrl/edit/" (please note the missing
id)

PHP will prompt me an error like this

Warning (2): Missing argument 1 for MyController::edit(), called in
[...]\cake\libs\object.php on line 116 and defined [app
\My_Controller.php, line 40]

right now i'm using a lot of

if (!isset($param)) $this->redirect("gg no re", "/". strtolower($this-
>name)));

but that's unconfortable...

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

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

Sunday, November 29, 2009

Captcha integration problem in cakePHP

Hi, I am cakePHP learner..
I am making an simple application like Quick post of jobs & in this I want to implement the Captcha in my form.For this I help from the link : http://bakery.cakephp.org/articles/view/improved-captcha-component

I have added captcha.php file to helper and to component as mentioned link above link...

but I am getting Problem like below if I run,
Notice (8): Undefined variable: captcha
Fatal error: Call to a member function input() on a non-object.

Please anybody help me to sort out this..

Thanks & Regards,
Vidya

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.
 
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+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en