Using CacheHelper to cache JSON views

2012-07-27 Thread Falagar
 

I cannot get this to work in 2.2. This is what I have tried:

First I just followed the book to create JSON views (
http://book.cakephp.org/2.0/en/views/json-and-xml-views.html). Works great. 
I get JSON data back.

Then I followed the CacheHelper instructions (
http://book.cakephp.org/2.0/en/core-libraries/helpers/cache.html). I 
un-commented Cache.check in core.php, added the CacheHelper in my 
Controller and defined $cacheAction. This works great for HTML Views. But, 
for JSON views nothing gets cached unfortunately.

I found this post: 
http://lars-schenk.com/cached-json-or-xml-view-with-cakephp/523 that ran 
into a similar issue (albeit in an earlier version of Cake that didn't have 
JsonView yet).

So I tried to use his method, and apply it to 2.2. I took 
Router::parseExtensions( 'json' ) out, took the RequestHandler out, created 
a json.ctp layout file.


!--nocache--?php
configure::write('debug',0); // surpress all debug output on json views
header('Content-type: text/x-json');?!--nocache--?php echo 
$this-fetch('content'); ?
 

a feed.ctp view file

?php echo json_encode( $data ); ?
 

and changed my controller action to just set the layout and data

$this-layout = 'json';$this-view = 'feed';$this-set( 'data', $data );
 

This works somewhat. I get the JSON file the first time, but when I request 
that action again, the response contains

!--nocache:001--!--nocache:002--
 

before the actual JSON data, so it won't work for my client app. I can see 
that chunk of text in the actual cache file as well, which I think is the 
problem.

So I am not quite sure how to proceed.

Am I just missing something painfully obvious?

Any help would be greatly appreciated.

-- 
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: Can't use components relying on startup() in beforeFilter

2007-06-18 Thread Falagar

Is it save to call the startup method manually?

I had a case where I wanted to use a cookie in beforeFilter and ended
up calling the startup method for the Cookie component manually and it
seems to work. Anything that's wrong with that or am I misusing
something?

On Jun 18, 5:02 am, AD7six [EMAIL PROTECTED] wrote:
 On Jun 18, 1:18 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

  Hi,

  In 1.1 and 1.2 Dispatcher::start() first calls beforeFilter() and then
  the startup methods of components. This leads to a situation where in
  beforeFilter() components are available (constructed) already, but
  their startup() method wasn't called yet - although you would expect
  that.

  Is it intentional to call beforeFilter first and initialize the
  components after?

 Components can have a initialize method, which is run immediately
 after they are instanciated, and a startup method which is run after
 the controller beforeFIlter.

 see the foreach loop in this 
 methodhttps://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/controlle...

 Note that components extend object, that link is to the cake class
 which handles instanciating components, it isn't the base class for
 them. The beforeFilter is run sometime after that. (handled in the
 dispatcher if you are curious)

 hth,

 AD


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



Re: Default Pagination options

2007-06-06 Thread Falagar

Just set var $order in the appropriate model and that naturally will
be the default order and direction for pagination as well.

On Jun 6, 11:15 am, rtconner [EMAIL PROTECTED] wrote:
 Ok, right now I'm leaning towards I've found a bug. But we'll see
 how this pans out.  Lets start here.. a simple quesiton... If this
 gets anwered, maybe there are no problems.

 What is the correct way to set the default pagination direction and
 column using the pagination in Cake 1.2?

 (FYI, a direction or sort column in the $paginate variable in the
 controller seems to not let that value ever change using the data from
 the url)


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



Re: $displayField with two items

2007-05-31 Thread Falagar

It doesn't work right away, but something like this does work:

In my player model:

  function afterFind($results) {
   foreach ($results as $key = $val) {
  if( isset( $val['Player'] ) ) {
$results[$key]['Player']['full_name'] =
  $val['Player']['first_name'] . ' ' . $val['Player']
['last_name'];
  }
  }
  return $results;
  }

and then you can set:

var $displayField = 'full_name';


On May 31, 10:49 am, gentleJuggernaut [EMAIL PROTECTED] wrote:
 When using the Scaffolding and declaring a $displayField in a foreign
 model, is there a way to specify two fields (i.e. var $displayField =
 'first_name' . 'last_name';)?


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



Re: How paginate results of search?

2007-05-23 Thread Falagar

In Cake 1.2, just use the paginator.

In your controller, have a search action which sets the search
conditions:

$this-paginate['conditions'] =  array('myfield' = 'mysearch' );
$this-set( 'mydata', $this-paginate() );

You might want to store the search conditions in the session, also, if
your search is supposed to by dynamic.

To find out how the view has to look like, just look at how 'index'
views are baked by the bake script (bake console shell, as of now).


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



Re: Arabic text in mysql

2007-05-08 Thread Falagar

Not sure if that will help, but have you also set utf8 in your db
config?

var $default = array(
'driver' = 'mysql',
'connect' = 'mysql_connect',
'host' = 'bla',
'login' = 'bla',
'password' = 'bla',
'database' = 'bla',
'prefix' = '',
'encoding' = 'UTF8'
  );

I believe this only works in 1.2. In 1.1 you need to set the encoding
manually (in some before... action in the appModel).


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



Re: Hello, World in CakePHP

2007-03-16 Thread Falagar

Hi,

the hello world example is probably easier to if if you just create
your 'hello' view in /app/views/pages/home.thtml (for 1.1 for 1.2
hello.ctp).

and then you call:

http://192.168.2.3/cake/app/pages/hello.

But Chris is right of course, you can also just follow the messages,
they will lead you to where you want to go.

The advantage with using the pages controller is that the controller
is already written for you, so you don't need to worry about writing
the views controller.


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



Translations

2007-02-25 Thread Falagar

Hi,

what is the state of the translation of the core files and how could
one use them? There are none in the trunk (removed in 4438 and no idea
where they went), http://translation.cakephp.org/ is not really useful
and http://cakeforge.org/projects/translations/ seems dead.

Also, will bake support baking files in different languages, right now
a lot seems to be hard-coded and does not use any locale files?

Mike


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



Re: Blank page of death

2007-02-24 Thread Falagar

@topic
I still haven't figured out why it didn't work but it only appeared
when using scaffolding, I baked my views, controllers and models now
and it works fine. I guess it is some server issue. (and yes the file
index.thtml cake tries to include is on the server, in the scaffolding
folder)

@subdomain
My host company has their webspace set up like this, I get a folder
www and put my files in there.

For cake, I create a folder www/cake. I uploaded my cake and app
directory into that directory (so I get www/cake/app and www/cake/
cake). Then I can configure where my domains link to, www.reya.de
for example links to www/reya. For the dev subdomain, I defined that
it will link to www/cake/app/webroot and it works like a charm(as
you can see now that it's working). :)

Think you need to link your subdomain to your app/webroot directory.
Hope that helped.


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



Blank page of death

2007-02-23 Thread Falagar

Hi, I am having a very strange issue on my webspace provider, this
does not happen on my local installation.

I tried to get Cake to work on my webspace (Cake 1.2, released
version), installed everything, database works. I implemented a simple
scaffolding app with two tables, articles and comments. And it
seems to work.

However, after entering some article, when I try to look at
http://dev.reya.de/articles Firefox returns a blank page. Totally
blank, no header, no content. Funny though, http://dev.reya.de/articles/edit/7
works just fine. (If anyone should give this a try, please don't
delete that entry, so this example will still work :) )

I debugged into this and it came down to around line 700 in /cake/libs/
view/view.php (in the _render function):

if (Configure::read()  0) {
include ($___viewFn);
} else {
@include ($___viewFn);
}

For debug purposes, I changed that to:

if (Configure::read()  0) {
$this-log('_render in view. #694, trying to include ' .
$___viewFn );
include ($___viewFn);
} else {
@include ($___viewFn);
}

$this-log('_render in view. #700.');

That's what the log file says (first /articles, then /articles/edit/7)

2007-02-23 18:13:45 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:46 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:46 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:47 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:48 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:48 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:49 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:49 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:50 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:50 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:13:51 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/index.thtml
2007-02-23 18:14:30 Debug: _render in view. #694, trying to include
cake/libs/view/templates/scaffolds/edit.thtml
2007-02-23 18:14:30 Debug: _render in view. #700.
2007-02-23 18:14:30 Debug: _render in view. #694, trying to include /
is/htdocs/wp1034476_1QHLDZ3T0M/www/cake/cake/libs/view/templates/
layouts/default.ctp
2007-02-23 18:14:30 Debug: _render in view. #700.

Configure::Read() is greater than zero, it tries to include $___viewFn
which is cake/libs/view/templates/scaffolds/index.thtml which seems
to be correct, the file exists. But after that it just dies. I tried
to put debug stuff into that file but it must die somewhere before
that. It doesn't really die that but it tries that about 10 times and
then I get the blank page. Why 10 times? Why does the blank page show
up?

Has anyone seen something like this before? I want to make sure this
works before I actually put more time in for development.

I tried to make sure all files don't end with spaces or newlines,
edited the db config correctly and /app/tmp is writable as well. Don't
know what to do. Any help is greatly appreciated.


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



Re: acl.php

2006-12-16 Thread Falagar

@Daniel
That has not fixed the problem for me. I have now gotten the fix for
the errors, the initdb call does not work yet though.

If I execute php acl.php initdb or php-cgi acl.php initdb with a
valid database connection in app no tables are created. So I just
executed the queries manually to create the tabes and could then work
with the application. One can find those queries in
app\config\sql\db_acl.sql.

@Joe
I also noticed that. For example, php acl.php view aco -app blabla
does not work: Wrong number of parameters: 3. I had to change the app
name in acl.php itself in line 36. Then everything worked fine.

Another thing that is not good is that php acl.php help does not work
when the database tables are not created yet. So you cannot find out
from the help that you need to call initdb, which doesn't work. :)


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



Re: php acl.php initdb failed

2006-12-15 Thread Falagar

This is a known bug that has been fixed in the trunk.

Either get the cake build from the trunk or fix it manually:

in cake\scripts\acl.php line 93 change:

uses ('object', 'neat_array', 'session', 'security', 'inflector',
'model'.DS.'connection_manager',
to
uses ('object', 'configure', 'neat_array', 'session', 'security',
'inflector', 'model'.DS.'connection_manager',

On Dec 15, 2:13 am, wong [EMAIL PROTECTED] wrote:
 Hi,
 I am a cakephp newbie.
 The latest cakephp, windows xp,
 When I run php acl.php initdb, the system response is:

 Fatal error: Class 'Configure' not found in
 C:\apache\Apache2\htdocs\cake\cake\libs\model\datasources\dbo_source.php
 on line 84
 
 Can you help me out?


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



Re: $html-tableHeaders using the colspan for a single TH

2006-12-14 Thread Falagar

The html Helper does not implement such a behavior. You either have
attributes for all th's or for none.

So you have a number of possibilities: you either don't use a helper
and write the HTML yourself (which shouldn't be hard).

Or (if you make use of this helper function very often and changing all
instances would be tedious) you write your own function (probably
similar to the one in html Helper) that does excactly what you want.

Another very ugly possibility would be to change the core html Helper
code to do what you want, which I do not recommend.

On Dec 14, 6:39 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 I need add an attribute for only a th, but the $helper extend to every
 TH.
 I want create a colspan for the 3 th.
 Ho I can?

 $thop=array(COLSPAN=1);
 $th = array (
 $pagination-sortBy('id'),
 $pagination-sortBy('title'),
 $pagination-sortBy('created'),
 Actions
 ); // Generate the pagination sort links
 echo $html-tableHeaders($th,null,$thop); // Create the table headers
 with sort links if desired
 
 Thanks!


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



acl.php

2006-12-05 Thread Falagar

Hi,

I tried to use the ACL example from the manual and ran into problems. I
have 1.1.11.4064 installed, the database connection is set up and I
have successfully baked stuff with bake.php.

When running php acl.php initdb -app blabla from /cake/scripts the
following error occurs:

Fatal error: Class 'Configure' not found in
C:\www\xampp\htdocs\cake\cake\libs\m
odel\datasources\dbo_source.php on line 84


I added the following lines in acl.php in a futile attempt to fix it:

require ('cake'.DS.'dispatcher.php');
require ('cake'.DS.'libs'.DS.'configure.php');

and the errors go away, however, now I get HTML code back telling me
this (abridged):

h1Missing Database Table/h1
p class=errorNo Database table for model Aro (expected aros),
create it first./p
pspan class=noticestrongNotice:/strong If you want to
customize this e
rror message, create
blabla\views/errors/missing_table.thtml./span/p

I looked a little bit further into the script but got lost. The
$command variable is set to 'initdb' correctly, but the switch
statement is never reached. Nor is the line: if (ACL_CLASSNAME !=
'DB_ACL'){.

But isn't the whole point of initdb to create those tables in the
database? Or am I just totally misunderstanding something? Any help is
greatly appreciated.

Mike


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