Re: Sending a 404 header from the controller

2014-07-14 Thread Alex Bovey
On Fri, Jul 11, 2014 at 2:31 PM, Alex Bovey a...@bovey.co.uk wrote:

 Hello all,

 I would like one of my controller methods to be able to send a 404 Not Found 
 header, but still render the view as normal.  I've tried both of the 
 following at the beginning of my controller method, but Cake is still 
 returning a 200 OK header:

 $this-response-header('HTTP/1.1 404 Not Found');
 $this-response-httpCodes(404);

Solved.  For anyone that finds this in future the function is
$this-response-statusCode(404) not $this-response- httpCodes(404).

Alex

-- 
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England  Wales no. 6471391 | VAT no. 934 8959 65
a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
PHP | CakePHP | MySQL | jQuery | HTML5 | CSS3 | Drupal | Wordpress | Hosting

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Sending a 404 header from the controller

2014-07-14 Thread euromark
+1 for correcting it here as reference for future findings

Am Montag, 14. Juli 2014 11:38:47 UTC+2 schrieb Alex Bovey:

 On Fri, Jul 11, 2014 at 2:31 PM, Alex Bovey al...@bovey.co.uk 
 javascript: wrote: 
  
  Hello all, 
  
  I would like one of my controller methods to be able to send a 404 Not 
 Found header, but still render the view as normal.  I've tried both of the 
 following at the beginning of my controller method, but Cake is still 
 returning a 200 OK header: 
  
  $this-response-header('HTTP/1.1 404 Not Found'); 
  $this-response-httpCodes(404); 

 Solved.  For anyone that finds this in future the function is 
 $this-response-statusCode(404) not $this-response- httpCodes(404). 

 Alex 

 -- 
 Alex Bovey 
 Web Developer | Alex Bovey Consultancy Ltd 
 Registered in England  Wales no. 6471391 | VAT no. 934 8959 65 
 al...@bovey.co.uk javascript: | t 0844 567 8995 | m 07828 649386 | f 
 0870 288 9533 
 PHP | CakePHP | MySQL | jQuery | HTML5 | CSS3 | Drupal | Wordpress | 
 Hosting 


-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Sending a 404 header from the controller

2014-07-11 Thread Alex Bovey
Hello all,

I would like one of my controller methods to be able to send a 404 Not
Found header, but still render the view as normal.  I've tried both of the
following at the beginning of my controller method, but Cake is still
returning a 200 OK header:

$this-response-header('HTTP/1.1 404 Not Found');
$this-response-httpCodes(404);

Please note that I don't just want to do a custom 404 page - I still want
to render the page using the current controller method.

I am using Cake 2.4.

Any help would be much appreciated.

Thanks all,

Alex

-- 
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England  Wales no. 6471391 | VAT no. 934 8959 65
a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
PHP | CakePHP | MySQL | jQuery | HTML5 | CSS3 | Drupal | Wordpress | Hosting

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Sending a 404 header from the controller

2014-07-11 Thread Leandro Machado Pereira
You should see this http://pastebin.com/zNB6SFg7


2014-07-11 10:31 GMT-03:00 Alex Bovey a...@bovey.co.uk:

 Hello all,

 I would like one of my controller methods to be able to send a 404 Not
 Found header, but still render the view as normal.  I've tried both of the
 following at the beginning of my controller method, but Cake is still
 returning a 200 OK header:

 $this-response-header('HTTP/1.1 404 Not Found');
 $this-response-httpCodes(404);

 Please note that I don't just want to do a custom 404 page - I still want
 to render the page using the current controller method.

 I am using Cake 2.4.

 Any help would be much appreciated.

 Thanks all,

 Alex

 --
 Alex Bovey
 Web Developer | Alex Bovey Consultancy Ltd
 Registered in England  Wales no. 6471391 | VAT no. 934 8959 65
 a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
 PHP | CakePHP | MySQL | jQuery | HTML5 | CSS3 | Drupal | Wordpress |
 Hosting

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




-- 


http://leandrompereira.com.br

***Se você pretende redirecionar este e-mail, por favor, apague todos os
endereços que aparecem nele. Outra dica de segurança é endereçá-lo no Cco.
Desta forma você estará protegendo a mim, seus amigos e a você mesmo. Eu e
a Campanha Contra o SPAM agradecemos.Não envie correntes.***

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.


Re: Sending a 404 header from the controller

2014-07-11 Thread Alex Bovey
Thank you Leandro - I can't see where that outputs a 404 header though?

Alex


On Fri, Jul 11, 2014 at 3:09 PM, Leandro Machado Pereira 
llperei...@gmail.com wrote:

 You should see this http://pastebin.com/zNB6SFg7


 2014-07-11 10:31 GMT-03:00 Alex Bovey a...@bovey.co.uk:

 Hello all,

 I would like one of my controller methods to be able to send a 404 Not
 Found header, but still render the view as normal.  I've tried both of the
 following at the beginning of my controller method, but Cake is still
 returning a 200 OK header:

 $this-response-header('HTTP/1.1 404 Not Found');
 $this-response-httpCodes(404);

 Please note that I don't just want to do a custom 404 page - I still want
 to render the page using the current controller method.

 I am using Cake 2.4.

 Any help would be much appreciated.

 Thanks all,

 Alex

 --
 Alex Bovey
 Web Developer | Alex Bovey Consultancy Ltd
 Registered in England  Wales no. 6471391 | VAT no. 934 8959 65
 a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
 PHP | CakePHP | MySQL | jQuery | HTML5 | CSS3 | Drupal | Wordpress |
 Hosting

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




 --


 http://leandrompereira.com.br

 ***Se você pretende redirecionar este e-mail, por favor, apague todos os
 endereços que aparecem nele. Outra dica de segurança é endereçá-lo no Cco.
 Desta forma você estará protegendo a mim, seus amigos e a você mesmo. Eu e
 a Campanha Contra o SPAM agradecemos.Não envie correntes.***

 --
 Like Us on FaceBook https://www.facebook.com/CakePHP
 Find us on Twitter http://twitter.com/CakePHP

 ---
 You received this message because you are subscribed to the Google Groups
 CakePHP group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to cake-php+unsubscr...@googlegroups.com.
 To post to this group, send email to cake-php@googlegroups.com.
 Visit this group at http://groups.google.com/group/cake-php.
 For more options, visit https://groups.google.com/d/optout.




-- 
Alex Bovey
Web Developer | Alex Bovey Consultancy Ltd
Registered in England  Wales no. 6471391 | VAT no. 934 8959 65
a...@bovey.co.uk | t 0844 567 8995 | m 07828 649386 | f 0870 288 9533
PHP | CakePHP | MySQL | jQuery | HTML5 | CSS3 | Drupal | Wordpress | Hosting

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
CakePHP group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cake-php+unsubscr...@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.