error baking on mac

2009-11-22 Thread mupet
Hi, previously im baking on windows environtment. Now I have an error
when baking on make,
cake bake  output "Could not open input file: /Users/mufti"
this is my PATH
echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/Applications/MAMP/bin/php5/bin:/Users/
mufti ali/Sites/cake/cake/console

Anybody have similiar problem? how to fix it?

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: changing model properties for recursive finds

2009-11-22 Thread Amit
Sounds like Containable is your answer - 
http://book.cakephp.org/view/474/Containable

On Nov 20, 3:58 pm, Josh  wrote:
> Hello,
>
> I was wondering if there is a prettier way to do this:
>
>         $this->Ielement->Mem->hasMany['Rep']['order'] = 'created
> DESC';
>
>         $this->Ielement->Mem->find(...
>
> It seems from the cake documentation I should be able to do something
> like:
>
>         $this->Ielement->Mem->Rep->order = 'created DESC';
>
> But, that doesn't work.
>
> Thanks.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: To Sanitize or not? :: Public Opinion

2009-11-22 Thread Walther
CakePHP already makes any user input save in save functions (with the
exception of updateAll).

My general rule of thumb, is not to filter user input on save, but on
display. This way you can see which users are trying malicious code
and take action accordingly.

On Nov 23, 1:12 am, robustsolution  wrote:
> you may sanitize somtimes, but you should always validate inputs
> (forms... urls http requests)

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Two user_id fields in a single table.

2009-11-22 Thread Amit
In your model for activity you would need to define the foreign key.
In this example user_id(customer) = "customer_id" and user_id(Customer
Service Agenet) = "csa_id":

var $belongsTo = array(
 'Customer' => array (
'classname' => 'User',
'foreignKey' => 'customer_id'
  ),
 'CSA' => array (
'classname' => 'User',
'foreignKey' => 'csa_id'
));



On Nov 20, 2:39 pm, Mohammad Raheel  wrote:
> Hi guys,
>
> I need to know how do i keep two user_id fields in a single table in
> CakePHP. For example:
>
> I have a "users" table. There are two type of users in this table. 1.
> Customers,  2. Customer Service Agents.
> I have another table "activity" which shall hold all activities
> performed on a customer and who (Customer Service Agent) performed
> that activity.
>
> users
> 
>
> id, username, role
> 1,   john,         Customer
> 2,   mate         Customer Service Agent
>
> activity
> --
>
> id, created,  title,                                      user_id
> (customer)      user_id (Customer Service Agent)
>
> 1   xxx        Agent called the customer
> John                              Mate
> 2         Agent changed customer's info
> John                              Mate
>
> Really need help with best practice how to do this in cake as i'm
> stuck here.
>
> Appreciate any help.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: render shared view file

2009-11-22 Thread Walther
This: 
http://bakery.cakephp.org/articles/view/generating-automatized-json-as-output

is exactly what you are looking for.

On Nov 18, 2:13 pm, ddaffy  wrote:
> hi!
>
> i'm using Router::parseExtensions('json') to be able to request data
> delivered in json format, and i've been wondering if there's a way to
> change view file that will be used to render data?
>
> if action test from Examples controller ( /examples/test ) is
> requested, default view (app/views/examples/test.ctp) is rendered with
> default layout (app/views/layouts/default.ctp).
>
> if /examples/test.json is requested app/views/examples/json/test.ctp
> is rendered with app/views/layouts/json/default.ctp layout.
>
> because i use unified way for passing variables to view, i don't need
> every action to have different view for json extension (app/views/
> examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and i
> would like to use e.g. app/views/shared/json.ctp. i know how to
> achieve this for single action, but i need a way to do this globally
> (in AppController).
>
> what i tried:
>
> funciton beforeRender() {
>         if ($this->RequestHandler->ext == 'json') {
>             $this->viewPath = 'shared';
>         }
>
> }
>
> results in rendering app/views/shared/.ctp
>
> funciton beforeRender() {
>         if ($this->RequestHandler->ext == 'json') {
>             $this->render('/shared/json');
>             // or: $this->render('shared/json');
>             // or: $this->render(null, null, '/shared/json');
>             // or variations..
>         }
>
> }
>
> result is empty.
>
> also i saw solution with creating new view class that will override
> render function and customising it, but it sounds like overkill to
> me..
>
> ideal solution in addition to setting $viewPath ($this->viewPath =
> 'shared') would be to change name of view file that will be requested
> for rendering, but haven't found a way to do that.
>
> any ideas would be appreciated.
> thanks. :)

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Sort by count (and other aggregate fields)

2009-11-22 Thread Dave
You ARE using MySQL, you are just using cake's wrapper functions.  If you
read about how to use GROUP BY, then you will see what you need to modify in
your find method to return the data that you want.

CakePHP's automagic can only do so much for you without a basic
understanding of the database you are working with.

On Mon, Nov 23, 2009 at 12:10 AM, death.au  wrote:

> But I'm not using mysql, I am using the paginator helper's built in
> functions...
>
> On Nov 23, 4:00 pm, Dave  wrote:
> > In MySQL you use the GROUP BY keyword to accomplish this
> >
> > On Sun, Nov 22, 2009 at 7:44 PM, death.au  wrote:
> > > I've been looking around, and haven't been able to find anything on
> > > this at all, and I was wondering if it was even possible to sort by a
> > > count of related models using the paginator.
> >
> > > Using the basic blog example, I would like to list all posts with the
> > > paginator, sorted by the number of comments. Is there any way to do
> > > this currently?
> >
> > > In future I would also like to sort by things like average rating and
> > > other aggregates, but I thought I'd begin with the basics.
> >
> > > --
> >
> > > You received this message because you are subscribed to the Google
> Groups
> > > "CakePHP" group.
> > > To post to this group, send email to cake-...@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=.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-...@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=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Sort by count (and other aggregate fields)

2009-11-22 Thread Andras Kende

A good way to do this is to add posts.comment_count field to your database and 
add counterache to the model like :

http://book.cakephp.org/view/816/counterCache-Cache-your-count

Andras Kende

On Nov 23, 2009, at 12:10 AM, death.au wrote:

> But I'm not using mysql, I am using the paginator helper's built in
> functions...
> 
> On Nov 23, 4:00 pm, Dave  wrote:
>> In MySQL you use the GROUP BY keyword to accomplish this
>> 
>> On Sun, Nov 22, 2009 at 7:44 PM, death.au  wrote:
>>> I've been looking around, and haven't been able to find anything on
>>> this at all, and I was wondering if it was even possible to sort by a
>>> count of related models using the paginator.
>> 
>>> Using the basic blog example, I would like to list all posts with the
>>> paginator, sorted by the number of comments. Is there any way to do
>>> this currently?
>> 
>>> In future I would also like to sort by things like average rating and
>>> other aggregates, but I thought I'd begin with the basics.
>> 
>>> --
>> 
>>> You received this message because you are subscribed to the Google Groups
>>> "CakePHP" group.
>>> To post to this group, send email to cake-...@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=.
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-...@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=.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Sort by count (and other aggregate fields)

2009-11-22 Thread death.au
But I'm not using mysql, I am using the paginator helper's built in
functions...

On Nov 23, 4:00 pm, Dave  wrote:
> In MySQL you use the GROUP BY keyword to accomplish this
>
> On Sun, Nov 22, 2009 at 7:44 PM, death.au  wrote:
> > I've been looking around, and haven't been able to find anything on
> > this at all, and I was wondering if it was even possible to sort by a
> > count of related models using the paginator.
>
> > Using the basic blog example, I would like to list all posts with the
> > paginator, sorted by the number of comments. Is there any way to do
> > this currently?
>
> > In future I would also like to sort by things like average rating and
> > other aggregates, but I thought I'd begin with the basics.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-...@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=.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Sort by count (and other aggregate fields)

2009-11-22 Thread Dave
In MySQL you use the GROUP BY keyword to accomplish this

On Sun, Nov 22, 2009 at 7:44 PM, death.au  wrote:

> I've been looking around, and haven't been able to find anything on
> this at all, and I was wondering if it was even possible to sort by a
> count of related models using the paginator.
>
> Using the basic blog example, I would like to list all posts with the
> paginator, sorted by the number of comments. Is there any way to do
> this currently?
>
> In future I would also like to sort by things like average rating and
> other aggregates, but I thought I'd begin with the basics.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-...@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=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Serious Help Needed

2009-11-22 Thread Dave
When you put it like that its so easy to understand. I read the
cookbook but your example is 100 times better and clearly explained
when you lay it out like that. thank you very much. that looks like
exactly what I need.

Good looking out!

Thanks,

Dave

On Nov 23, 1:29 am, Amit  wrote:
> Take a look at the CakeBook 
> -http://book.cakephp.org/view/127/One-Rule-Per-Field
>
> var $validate = array(
>     'email' => array(
>         'rule' => array('email', 'isUnique'),
>         'required' => true,
>         'allowEmpty' => false,
>         'on' => 'create',
>         'message' => 'Your Error Message'
>     ),
>     'email' => array(
>         'rule' => array('email', 'isUnique'),
>         'allowEmpty' => false,
>         'on' => 'update',
>         'message' => 'Your Error Message'
>     ),
>     'url' => array(
>         'rule' => array('url', 'isUnique'),
>         'required' => true,
>         'allowEmpty' => false,
>         'on' => 'create',
>         'message' => 'Your Error Message'
>     ),
>     'url' => array(
>         'rule' => array('url', 'isUnique'),
>         'allowEmpty' => false,
>         'on' => 'update',
>         'message' => 'Your Error Message'
>     ),
>
> );
>
> On Nov 22, 8:45 pm, Dave  wrote:
>
> > I cant figure out how to do this.
> > I have 2  fields, an email and a url, both are required and need to be
> > unique when a user wants to update thier info.
>
> > If the user is only updating 1 field the other required will fail
> > because its required. If they enter in the email field their current
> > email because it says required it will come back invalid because its
> > no longer unique. Vice versa for the url.
>
> > They may only want to change one of the 2 fields information but how
> > can you get around this? I dont want them entering in anything thats
> > not valid for email / url so i need the validation rules. They are
> > both required but how can they edit just 1 field?
>
> > Thanks,
>
> > Dave
>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Serious Help Needed

2009-11-22 Thread Amit
Take a look at the CakeBook - 
http://book.cakephp.org/view/127/One-Rule-Per-Field

var $validate = array(
'email' => array(
'rule' => array('email', 'isUnique'),
'required' => true,
'allowEmpty' => false,
'on' => 'create',
'message' => 'Your Error Message'
),
'email' => array(
'rule' => array('email', 'isUnique'),
'allowEmpty' => false,
'on' => 'update',
'message' => 'Your Error Message'
),
'url' => array(
'rule' => array('url', 'isUnique'),
'required' => true,
'allowEmpty' => false,
'on' => 'create',
'message' => 'Your Error Message'
),
'url' => array(
'rule' => array('url', 'isUnique'),
'allowEmpty' => false,
'on' => 'update',
'message' => 'Your Error Message'
),

);

On Nov 22, 8:45 pm, Dave  wrote:
> I cant figure out how to do this.
> I have 2  fields, an email and a url, both are required and need to be
> unique when a user wants to update thier info.
>
> If the user is only updating 1 field the other required will fail
> because its required. If they enter in the email field their current
> email because it says required it will come back invalid because its
> no longer unique. Vice versa for the url.
>
> They may only want to change one of the 2 fields information but how
> can you get around this? I dont want them entering in anything thats
> not valid for email / url so i need the validation rules. They are
> both required but how can they edit just 1 field?
>
> Thanks,
>
> Dave

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Two user_id fields in a single table.

2009-11-22 Thread Mohammad Raheel
Hi guys,

I need to know how do i keep two user_id fields in a single table in
CakePHP. For example:

I have a "users" table. There are two type of users in this table. 1.
Customers,  2. Customer Service Agents.
I have another table "activity" which shall hold all activities
performed on a customer and who (Customer Service Agent) performed
that activity.


users


id, username, role
1,   john, Customer
2,   mate Customer Service Agent


activity
--

id, created,  title,  user_id
(customer)  user_id (Customer Service Agent)

1   xxxAgent called the customer
John  Mate
2     Agent changed customer's info
John  Mate


Really need help with best practice how to do this in cake as i'm
stuck here.

Appreciate any help.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Serious Help Needed

2009-11-22 Thread death.au
You could omit the 'required' => true in the validation rules and keep
an 'allowEmpty' => false instead. This way upon sign up both fields
need to be filled in, but on changing, you don't need to submit both.
For the 'unique' problem, you might have to check if the email is the
same as what is already saved, and if so, don't bother saving it.

On Nov 23, 1:45 pm, Dave  wrote:
> I cant figure out how to do this.
> I have 2  fields, an email and a url, both are required and need to be
> unique when a user wants to update thier info.
>
> If the user is only updating 1 field the other required will fail
> because its required. If they enter in the email field their current
> email because it says required it will come back invalid because its
> no longer unique. Vice versa for the url.
>
> They may only want to change one of the 2 fields information but how
> can you get around this? I dont want them entering in anything thats
> not valid for email / url so i need the validation rules. They are
> both required but how can they edit just 1 field?
>
> Thanks,
>
> Dave

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Serious Help Needed

2009-11-22 Thread Dave
I cant figure out how to do this.
I have 2  fields, an email and a url, both are required and need to be
unique when a user wants to update thier info.

If the user is only updating 1 field the other required will fail
because its required. If they enter in the email field their current
email because it says required it will come back invalid because its
no longer unique. Vice versa for the url.

They may only want to change one of the 2 fields information but how
can you get around this? I dont want them entering in anything thats
not valid for email / url so i need the validation rules. They are
both required but how can they edit just 1 field?

Thanks,

Dave

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: render shared view file

2009-11-22 Thread Amit
Don't know if my last post made it but I found a better solution
(since afterRender doesn't exist and I was changing the action
variable):

function render($action = null, $layout = null, $file = null){
 if ($this->RequestHandler->ext == 'json') {
  return parent::render($action, $layout, '/share/json'); //loads /app/
views/shared/json.ctp
 }
 return parent::render($action, $layout, $file);
}

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: render shared view file

2009-11-22 Thread Amit
Whoops there is no afterRender. Did a little thinking and here's a
better solution (put this in your app_controller.php):

function render($action = null, $layout = null, $file = null) {
if ($this->RequestHandler->ext == 'json') {
return parent::render($action, $layout, '/shared/
json');
}

return parent::render($action, $layout, $file);
}

On Nov 22, 6:59 pm, Amit  wrote:
> To be clear that would always load for requests with a json extension:
>
> app/views/shared/json.ctp
>
> On Nov 22, 6:58 pm, Amit  wrote:
>
>
>
> > What if you just override the action?
>
> > funciton beforeRender() {
> >         if ($this->RequestHandler->ext == 'json') {
> >                 $this->real_action = $this->action;
> >                 $this->action = "json";
> >                 $this->viewPath = "shared";
> >         }
>
> > }
>
> > function afterRender(){
> >         if ($this->RequestHandler->ext == 'json') {
> >                 $this->action = $this->real_action;
> >         }}
>
> > On Nov 22, 5:30 pm, ddaffy  wrote:
>
> > > sure, i can do that, and it works really fine. but problem is, if you
> > > read first post, i need a way to do this on all actions, in
> > > AppController or SomeController, depending on extension (.json in this
> > > case).
>
> > > On Nov 22, 4:14 pm, Dave  wrote:
>
> > > > You just call it right from the action
>
> > > > On Sun, Nov 22, 2009 at 9:39 AM, ddaffy  wrote:
> > > > > thanks for replies guys. :)
>
> > > > > i came to a conclusion that i can't use render() function for this
> > > > > purpose. reason is there are three callbacks i could place this call
> > > > > in:
> > > > > - AppController::beforeFilter() - won't work because it's called
> > > > > before action
> > > > > - AppController::beforeRender() - won't work because it'll go into
> > > > > infinite loop (render() calls beforeRender())
> > > > > - AppController::afterFilter() - won't work because rendering is
> > > > > already done
>
> > > > > only thing i see, that would solve this, is that some variable which
> > > > > would specify name of view file is added to controller (like $layout),
> > > > > and used in render() action to determine view file. if some other
> > > > > solution doesn't come up, i'll post feature request. maybe i get
> > > > > lucky. :)
>
> > > > > cheers
>
> > > > > On Nov 19, 8:25 am, David Roda  wrote:
> > > > > > Last response I promise!
>
> > > > > > I read the whole post this time... If you want to change the view 
> > > > > > that is
> > > > > > rendered for an action you can manually call $this->render .  Also 
> > > > > > the
> > > > > > target action can be tested for with $this->action if you need to 
> > > > > > test
> > > > > for
> > > > > > specific cases.
>
> > > > > > On Thu, Nov 19, 2009 at 2:22 AM, David Roda 
> > > > > wrote:
> > > > > > > I'm sorry its late... I didn't even read your post... please 
> > > > > > > ignore my
> > > > > > > reply! =(
>
> > > > > > > On Thu, Nov 19, 2009 at 2:21 AM, David Roda 
> > > > > wrote:
>
> > > > > > >> I think you can use the RequestHandler component for this.
> > > > > > >>http://book.cakephp.org/view/174/Request-Handling
>
> > > > > > >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto 
> > > > > wrote:
>
> > > > > > >>> There is a hack to render view from other folder: $this->render
> > > > > > >>> ('..'.DS.'shared'.DS.'json');
>
> > > > > > >>> On Nov 18, 6:13 pm, ddaffy  wrote:
> > > > > > >>> > hi!
>
> > > > > > >>> > i'm using Router::parseExtensions('json') to be able to 
> > > > > > >>> > request
> > > > > data
> > > > > > >>> > delivered in json format, and i've been wondering if there's 
> > > > > > >>> > a way
> > > > > to
> > > > > > >>> > change view file that will be used to render data?
>
> > > > > > >>> > if action test from Examples controller ( /examples/test ) is
> > > > > > >>> > requested, default view (app/views/examples/test.ctp) is 
> > > > > > >>> > rendered
> > > > > with
> > > > > > >>> > default layout (app/views/layouts/default.ctp).
>
> > > > > > >>> > if /examples/test.json is requested
> > > > > app/views/examples/json/test.ctp
> > > > > > >>> > is rendered with app/views/layouts/json/default.ctp layout.
>
> > > > > > >>> > because i use unified way for passing variables to view, i 
> > > > > > >>> > don't
> > > > > need
> > > > > > >>> > every action to have different view for json extension 
> > > > > > >>> > (app/views/
> > > > > > >>> > examples/json/test1.ctp, 
> > > > > > >>> > app/views/examples/json/test2.ctp...), and
> > > > > i
> > > > > > >>> > would like to use e.g. app/views/shared/json.ctp. i know how 
> > > > > > >>> > to
> > > > > > >>> > achieve this for single action, but i need a way to do this
> > > > > globally
> > > > > > >>> > (in AppController).
>
> > > > > > >>> > what i tried:
>
> > > > > > >>> > funciton beforeRender() {
> > > > > > >>> >         if ($this->RequestHandler->ext == 'json') {
> > > > > > >>> >             $this->viewPath = 'shared';
> > > > > 

Re: render shared view file

2009-11-22 Thread Amit
To be clear that would always load for requests with a json extension:

app/views/shared/json.ctp

On Nov 22, 6:58 pm, Amit  wrote:
> What if you just override the action?
>
> funciton beforeRender() {
>         if ($this->RequestHandler->ext == 'json') {
>                 $this->real_action = $this->action;
>                 $this->action = "json";
>                 $this->viewPath = "shared";
>         }
>
> }
>
> function afterRender(){
>         if ($this->RequestHandler->ext == 'json') {
>                 $this->action = $this->real_action;
>         }}
>
> On Nov 22, 5:30 pm, ddaffy  wrote:
>
>
>
> > sure, i can do that, and it works really fine. but problem is, if you
> > read first post, i need a way to do this on all actions, in
> > AppController or SomeController, depending on extension (.json in this
> > case).
>
> > On Nov 22, 4:14 pm, Dave  wrote:
>
> > > You just call it right from the action
>
> > > On Sun, Nov 22, 2009 at 9:39 AM, ddaffy  wrote:
> > > > thanks for replies guys. :)
>
> > > > i came to a conclusion that i can't use render() function for this
> > > > purpose. reason is there are three callbacks i could place this call
> > > > in:
> > > > - AppController::beforeFilter() - won't work because it's called
> > > > before action
> > > > - AppController::beforeRender() - won't work because it'll go into
> > > > infinite loop (render() calls beforeRender())
> > > > - AppController::afterFilter() - won't work because rendering is
> > > > already done
>
> > > > only thing i see, that would solve this, is that some variable which
> > > > would specify name of view file is added to controller (like $layout),
> > > > and used in render() action to determine view file. if some other
> > > > solution doesn't come up, i'll post feature request. maybe i get
> > > > lucky. :)
>
> > > > cheers
>
> > > > On Nov 19, 8:25 am, David Roda  wrote:
> > > > > Last response I promise!
>
> > > > > I read the whole post this time... If you want to change the view 
> > > > > that is
> > > > > rendered for an action you can manually call $this->render .  Also the
> > > > > target action can be tested for with $this->action if you need to test
> > > > for
> > > > > specific cases.
>
> > > > > On Thu, Nov 19, 2009 at 2:22 AM, David Roda 
> > > > wrote:
> > > > > > I'm sorry its late... I didn't even read your post... please ignore 
> > > > > > my
> > > > > > reply! =(
>
> > > > > > On Thu, Nov 19, 2009 at 2:21 AM, David Roda 
> > > > wrote:
>
> > > > > >> I think you can use the RequestHandler component for this.
> > > > > >>http://book.cakephp.org/view/174/Request-Handling
>
> > > > > >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto 
> > > > wrote:
>
> > > > > >>> There is a hack to render view from other folder: $this->render
> > > > > >>> ('..'.DS.'shared'.DS.'json');
>
> > > > > >>> On Nov 18, 6:13 pm, ddaffy  wrote:
> > > > > >>> > hi!
>
> > > > > >>> > i'm using Router::parseExtensions('json') to be able to request
> > > > data
> > > > > >>> > delivered in json format, and i've been wondering if there's a 
> > > > > >>> > way
> > > > to
> > > > > >>> > change view file that will be used to render data?
>
> > > > > >>> > if action test from Examples controller ( /examples/test ) is
> > > > > >>> > requested, default view (app/views/examples/test.ctp) is 
> > > > > >>> > rendered
> > > > with
> > > > > >>> > default layout (app/views/layouts/default.ctp).
>
> > > > > >>> > if /examples/test.json is requested
> > > > app/views/examples/json/test.ctp
> > > > > >>> > is rendered with app/views/layouts/json/default.ctp layout.
>
> > > > > >>> > because i use unified way for passing variables to view, i don't
> > > > need
> > > > > >>> > every action to have different view for json extension 
> > > > > >>> > (app/views/
> > > > > >>> > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), 
> > > > > >>> > and
> > > > i
> > > > > >>> > would like to use e.g. app/views/shared/json.ctp. i know how to
> > > > > >>> > achieve this for single action, but i need a way to do this
> > > > globally
> > > > > >>> > (in AppController).
>
> > > > > >>> > what i tried:
>
> > > > > >>> > funciton beforeRender() {
> > > > > >>> >         if ($this->RequestHandler->ext == 'json') {
> > > > > >>> >             $this->viewPath = 'shared';
> > > > > >>> >         }
>
> > > > > >>> > }
>
> > > > > >>> > results in rendering app/views/shared/.ctp
>
> > > > > >>> > funciton beforeRender() {
> > > > > >>> >         if ($this->RequestHandler->ext == 'json') {
> > > > > >>> >             $this->render('/shared/json');
> > > > > >>> >             // or: $this->render('shared/json');
> > > > > >>> >             // or: $this->render(null, null, '/shared/json');
> > > > > >>> >             // or variations..
> > > > > >>> >         }
>
> > > > > >>> > }
>
> > > > > >>> > result is empty.
>
> > > > > >>> > also i saw solution with creating new view class that will 
> > > > > >>> > override
> > > > > >>> > render function and customi

Re: render shared view file

2009-11-22 Thread Amit
What if you just override the action?

funciton beforeRender() {
if ($this->RequestHandler->ext == 'json') {
$this->real_action = $this->action;
$this->action = "json";
$this->viewPath = "shared";
}
}


function afterRender(){
if ($this->RequestHandler->ext == 'json') {
$this->action = $this->real_action;
}
}
On Nov 22, 5:30 pm, ddaffy  wrote:
> sure, i can do that, and it works really fine. but problem is, if you
> read first post, i need a way to do this on all actions, in
> AppController or SomeController, depending on extension (.json in this
> case).
>
> On Nov 22, 4:14 pm, Dave  wrote:
>
>
>
> > You just call it right from the action
>
> > On Sun, Nov 22, 2009 at 9:39 AM, ddaffy  wrote:
> > > thanks for replies guys. :)
>
> > > i came to a conclusion that i can't use render() function for this
> > > purpose. reason is there are three callbacks i could place this call
> > > in:
> > > - AppController::beforeFilter() - won't work because it's called
> > > before action
> > > - AppController::beforeRender() - won't work because it'll go into
> > > infinite loop (render() calls beforeRender())
> > > - AppController::afterFilter() - won't work because rendering is
> > > already done
>
> > > only thing i see, that would solve this, is that some variable which
> > > would specify name of view file is added to controller (like $layout),
> > > and used in render() action to determine view file. if some other
> > > solution doesn't come up, i'll post feature request. maybe i get
> > > lucky. :)
>
> > > cheers
>
> > > On Nov 19, 8:25 am, David Roda  wrote:
> > > > Last response I promise!
>
> > > > I read the whole post this time... If you want to change the view that 
> > > > is
> > > > rendered for an action you can manually call $this->render .  Also the
> > > > target action can be tested for with $this->action if you need to test
> > > for
> > > > specific cases.
>
> > > > On Thu, Nov 19, 2009 at 2:22 AM, David Roda 
> > > wrote:
> > > > > I'm sorry its late... I didn't even read your post... please ignore my
> > > > > reply! =(
>
> > > > > On Thu, Nov 19, 2009 at 2:21 AM, David Roda 
> > > wrote:
>
> > > > >> I think you can use the RequestHandler component for this.
> > > > >>http://book.cakephp.org/view/174/Request-Handling
>
> > > > >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto 
> > > wrote:
>
> > > > >>> There is a hack to render view from other folder: $this->render
> > > > >>> ('..'.DS.'shared'.DS.'json');
>
> > > > >>> On Nov 18, 6:13 pm, ddaffy  wrote:
> > > > >>> > hi!
>
> > > > >>> > i'm using Router::parseExtensions('json') to be able to request
> > > data
> > > > >>> > delivered in json format, and i've been wondering if there's a way
> > > to
> > > > >>> > change view file that will be used to render data?
>
> > > > >>> > if action test from Examples controller ( /examples/test ) is
> > > > >>> > requested, default view (app/views/examples/test.ctp) is rendered
> > > with
> > > > >>> > default layout (app/views/layouts/default.ctp).
>
> > > > >>> > if /examples/test.json is requested
> > > app/views/examples/json/test.ctp
> > > > >>> > is rendered with app/views/layouts/json/default.ctp layout.
>
> > > > >>> > because i use unified way for passing variables to view, i don't
> > > need
> > > > >>> > every action to have different view for json extension (app/views/
> > > > >>> > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), 
> > > > >>> > and
> > > i
> > > > >>> > would like to use e.g. app/views/shared/json.ctp. i know how to
> > > > >>> > achieve this for single action, but i need a way to do this
> > > globally
> > > > >>> > (in AppController).
>
> > > > >>> > what i tried:
>
> > > > >>> > funciton beforeRender() {
> > > > >>> >         if ($this->RequestHandler->ext == 'json') {
> > > > >>> >             $this->viewPath = 'shared';
> > > > >>> >         }
>
> > > > >>> > }
>
> > > > >>> > results in rendering app/views/shared/.ctp
>
> > > > >>> > funciton beforeRender() {
> > > > >>> >         if ($this->RequestHandler->ext == 'json') {
> > > > >>> >             $this->render('/shared/json');
> > > > >>> >             // or: $this->render('shared/json');
> > > > >>> >             // or: $this->render(null, null, '/shared/json');
> > > > >>> >             // or variations..
> > > > >>> >         }
>
> > > > >>> > }
>
> > > > >>> > result is empty.
>
> > > > >>> > also i saw solution with creating new view class that will 
> > > > >>> > override
> > > > >>> > render function and customising it, but it sounds like overkill to
> > > > >>> > me..
>
> > > > >>> > ideal solution in addition to setting $viewPath ($this->viewPath =
> > > > >>> > 'shared') would be to change name of view file that will be
> > > requested
> > > > >>> > for rendering, but haven't found a way to do that.
>
> > > > >>> > any ideas would be appreciated.
> > > > >>> > thanks. :)
>
> > > > >>> --
>
> > > > >>>

Sort by count (and other aggregate fields)

2009-11-22 Thread death.au
I've been looking around, and haven't been able to find anything on
this at all, and I was wondering if it was even possible to sort by a
count of related models using the paginator.

Using the basic blog example, I would like to list all posts with the
paginator, sorted by the number of comments. Is there any way to do
this currently?

In future I would also like to sort by things like average rating and
other aggregates, but I thought I'd begin with the basics.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: render shared view file

2009-11-22 Thread ddaffy
sure, i can do that, and it works really fine. but problem is, if you
read first post, i need a way to do this on all actions, in
AppController or SomeController, depending on extension (.json in this
case).

On Nov 22, 4:14 pm, Dave  wrote:
> You just call it right from the action
>
>
>
> On Sun, Nov 22, 2009 at 9:39 AM, ddaffy  wrote:
> > thanks for replies guys. :)
>
> > i came to a conclusion that i can't use render() function for this
> > purpose. reason is there are three callbacks i could place this call
> > in:
> > - AppController::beforeFilter() - won't work because it's called
> > before action
> > - AppController::beforeRender() - won't work because it'll go into
> > infinite loop (render() calls beforeRender())
> > - AppController::afterFilter() - won't work because rendering is
> > already done
>
> > only thing i see, that would solve this, is that some variable which
> > would specify name of view file is added to controller (like $layout),
> > and used in render() action to determine view file. if some other
> > solution doesn't come up, i'll post feature request. maybe i get
> > lucky. :)
>
> > cheers
>
> > On Nov 19, 8:25 am, David Roda  wrote:
> > > Last response I promise!
>
> > > I read the whole post this time... If you want to change the view that is
> > > rendered for an action you can manually call $this->render .  Also the
> > > target action can be tested for with $this->action if you need to test
> > for
> > > specific cases.
>
> > > On Thu, Nov 19, 2009 at 2:22 AM, David Roda 
> > wrote:
> > > > I'm sorry its late... I didn't even read your post... please ignore my
> > > > reply! =(
>
> > > > On Thu, Nov 19, 2009 at 2:21 AM, David Roda 
> > wrote:
>
> > > >> I think you can use the RequestHandler component for this.
> > > >>http://book.cakephp.org/view/174/Request-Handling
>
> > > >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto 
> > wrote:
>
> > > >>> There is a hack to render view from other folder: $this->render
> > > >>> ('..'.DS.'shared'.DS.'json');
>
> > > >>> On Nov 18, 6:13 pm, ddaffy  wrote:
> > > >>> > hi!
>
> > > >>> > i'm using Router::parseExtensions('json') to be able to request
> > data
> > > >>> > delivered in json format, and i've been wondering if there's a way
> > to
> > > >>> > change view file that will be used to render data?
>
> > > >>> > if action test from Examples controller ( /examples/test ) is
> > > >>> > requested, default view (app/views/examples/test.ctp) is rendered
> > with
> > > >>> > default layout (app/views/layouts/default.ctp).
>
> > > >>> > if /examples/test.json is requested
> > app/views/examples/json/test.ctp
> > > >>> > is rendered with app/views/layouts/json/default.ctp layout.
>
> > > >>> > because i use unified way for passing variables to view, i don't
> > need
> > > >>> > every action to have different view for json extension (app/views/
> > > >>> > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and
> > i
> > > >>> > would like to use e.g. app/views/shared/json.ctp. i know how to
> > > >>> > achieve this for single action, but i need a way to do this
> > globally
> > > >>> > (in AppController).
>
> > > >>> > what i tried:
>
> > > >>> > funciton beforeRender() {
> > > >>> >         if ($this->RequestHandler->ext == 'json') {
> > > >>> >             $this->viewPath = 'shared';
> > > >>> >         }
>
> > > >>> > }
>
> > > >>> > results in rendering app/views/shared/.ctp
>
> > > >>> > funciton beforeRender() {
> > > >>> >         if ($this->RequestHandler->ext == 'json') {
> > > >>> >             $this->render('/shared/json');
> > > >>> >             // or: $this->render('shared/json');
> > > >>> >             // or: $this->render(null, null, '/shared/json');
> > > >>> >             // or variations..
> > > >>> >         }
>
> > > >>> > }
>
> > > >>> > result is empty.
>
> > > >>> > also i saw solution with creating new view class that will override
> > > >>> > render function and customising it, but it sounds like overkill to
> > > >>> > me..
>
> > > >>> > ideal solution in addition to setting $viewPath ($this->viewPath =
> > > >>> > 'shared') would be to change name of view file that will be
> > requested
> > > >>> > for rendering, but haven't found a way to do that.
>
> > > >>> > any ideas would be appreciated.
> > > >>> > thanks. :)
>
> > > >>> --
>
> > > >>> You received this message because you are subscribed to the Google
> > Groups
> > > >>> "CakePHP" group.
> > > >>> To post to this group, send email to cake-...@googlegroups.com.
> > > >>> To unsubscribe from this group, send email to
> > > >>> cake-php+unsubscr...@googlegroups.com > > >>>  om>
> > 
> > > >>> .
> > > >>> For more options, visit this group at
> > > >>>http://groups.google.com/group/cake-php?hl=.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "CakePHP" group.
> > To post to this group, send email to cake-...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > cake-php+unsubscr...

Re: To Sanitize or not? :: Public Opinion

2009-11-22 Thread robustsolution
you may sanitize somtimes, but you should always validate inputs
(forms... urls http requests)

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




cake-php@googlegroups.com

2009-11-22 Thread Amit
Is there a reason you can't just include the vars in the form?

$form->input('var', array('type'=>'hidden', 'value'=> 'b73cr6xzr6z'));

On Nov 22, 12:54 pm, Ragnis  wrote:
> So how can i do that?
> And i don't want to use /Accounts/Manage/var:b73cr6xzr6z/
> var2:somethingelse

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




cake-php@googlegroups.com

2009-11-22 Thread Ragnis
So how can i do that?
And i don't want to use /Accounts/Manage/var:b73cr6xzr6z/
var2:somethingelse

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Contain Question

2009-11-22 Thread Dave
My User.id is my Profile.id. When a user is created thier profile is
created same time and a UUID for the User is used for the Profile.id.
The models are related using Profile.id and User.id

Seemed pointless to have Profile.user_id = 1234-5678-910 and
Profile.id 1234-5678-910 since they are the same

Thanks, any other ideas?

On Nov 22, 8:16 am, gaga  wrote:
> Where you set Profile fields include 'Profile.user_id'.
>
> On Nov 21, 5:47 am, Dave  wrote:
>
> > Wondering why when I specify fields in this contain for User I cant
> > get and of the related Profile fields?
>
> > If i remove 'fields' from the User it pulls all User fields and then I
> > get my Profile fields but I dont want all my User fields, just the few
> > i need. What am I doing wrong here?
>
> > public function getUser($auth_id)
> >         //this fetches basic info for the profile view/index
> >         {
> >                 $params = array(
> >                'conditions' => array(
> >                                 'User.id' => $auth_id),
> >                         'fields' => array(
> >                                 'User.firstname',
> >                                 'User.lastname',
> >                                 'User.username',
> >                                 'User.email',
> >                                 'User.slug',
> >                                 'User.id',
> >                                 'User.reset',
> >                                 'User.confirm_code'),
> >                         'contain' => array(
> >                                 'Profile' => array(
> >                                         'fields' => array(
> >                                                 'Profile.id',
> >                                                 'Profile.email';
>
> >                 $q = $this->find('first', $params);
> >               return $q;
> >         }
>
>

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: render shared view file

2009-11-22 Thread Dave
You just call it right from the action

On Sun, Nov 22, 2009 at 9:39 AM, ddaffy  wrote:

> thanks for replies guys. :)
>
> i came to a conclusion that i can't use render() function for this
> purpose. reason is there are three callbacks i could place this call
> in:
> - AppController::beforeFilter() - won't work because it's called
> before action
> - AppController::beforeRender() - won't work because it'll go into
> infinite loop (render() calls beforeRender())
> - AppController::afterFilter() - won't work because rendering is
> already done
>
> only thing i see, that would solve this, is that some variable which
> would specify name of view file is added to controller (like $layout),
> and used in render() action to determine view file. if some other
> solution doesn't come up, i'll post feature request. maybe i get
> lucky. :)
>
> cheers
>
> On Nov 19, 8:25 am, David Roda  wrote:
> > Last response I promise!
> >
> > I read the whole post this time... If you want to change the view that is
> > rendered for an action you can manually call $this->render .  Also the
> > target action can be tested for with $this->action if you need to test
> for
> > specific cases.
> >
> >
> >
> > On Thu, Nov 19, 2009 at 2:22 AM, David Roda 
> wrote:
> > > I'm sorry its late... I didn't even read your post... please ignore my
> > > reply! =(
> >
> > > On Thu, Nov 19, 2009 at 2:21 AM, David Roda 
> wrote:
> >
> > >> I think you can use the RequestHandler component for this.
> > >>http://book.cakephp.org/view/174/Request-Handling
> >
> > >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto 
> wrote:
> >
> > >>> There is a hack to render view from other folder: $this->render
> > >>> ('..'.DS.'shared'.DS.'json');
> >
> > >>> On Nov 18, 6:13 pm, ddaffy  wrote:
> > >>> > hi!
> >
> > >>> > i'm using Router::parseExtensions('json') to be able to request
> data
> > >>> > delivered in json format, and i've been wondering if there's a way
> to
> > >>> > change view file that will be used to render data?
> >
> > >>> > if action test from Examples controller ( /examples/test ) is
> > >>> > requested, default view (app/views/examples/test.ctp) is rendered
> with
> > >>> > default layout (app/views/layouts/default.ctp).
> >
> > >>> > if /examples/test.json is requested
> app/views/examples/json/test.ctp
> > >>> > is rendered with app/views/layouts/json/default.ctp layout.
> >
> > >>> > because i use unified way for passing variables to view, i don't
> need
> > >>> > every action to have different view for json extension (app/views/
> > >>> > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and
> i
> > >>> > would like to use e.g. app/views/shared/json.ctp. i know how to
> > >>> > achieve this for single action, but i need a way to do this
> globally
> > >>> > (in AppController).
> >
> > >>> > what i tried:
> >
> > >>> > funciton beforeRender() {
> > >>> > if ($this->RequestHandler->ext == 'json') {
> > >>> > $this->viewPath = 'shared';
> > >>> > }
> >
> > >>> > }
> >
> > >>> > results in rendering app/views/shared/.ctp
> >
> > >>> > funciton beforeRender() {
> > >>> > if ($this->RequestHandler->ext == 'json') {
> > >>> > $this->render('/shared/json');
> > >>> > // or: $this->render('shared/json');
> > >>> > // or: $this->render(null, null, '/shared/json');
> > >>> > // or variations..
> > >>> > }
> >
> > >>> > }
> >
> > >>> > result is empty.
> >
> > >>> > also i saw solution with creating new view class that will override
> > >>> > render function and customising it, but it sounds like overkill to
> > >>> > me..
> >
> > >>> > ideal solution in addition to setting $viewPath ($this->viewPath =
> > >>> > 'shared') would be to change name of view file that will be
> requested
> > >>> > for rendering, but haven't found a way to do that.
> >
> > >>> > any ideas would be appreciated.
> > >>> > thanks. :)
> >
> > >>> --
> >
> > >>> You received this message because you are subscribed to the Google
> Groups
> > >>> "CakePHP" group.
> > >>> To post to this group, send email to cake-...@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=.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-...@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=.
>
>
>

--

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

Re: render shared view file

2009-11-22 Thread ddaffy
thanks for replies guys. :)

i came to a conclusion that i can't use render() function for this
purpose. reason is there are three callbacks i could place this call
in:
- AppController::beforeFilter() - won't work because it's called
before action
- AppController::beforeRender() - won't work because it'll go into
infinite loop (render() calls beforeRender())
- AppController::afterFilter() - won't work because rendering is
already done

only thing i see, that would solve this, is that some variable which
would specify name of view file is added to controller (like $layout),
and used in render() action to determine view file. if some other
solution doesn't come up, i'll post feature request. maybe i get
lucky. :)

cheers

On Nov 19, 8:25 am, David Roda  wrote:
> Last response I promise!
>
> I read the whole post this time... If you want to change the view that is
> rendered for an action you can manually call $this->render .  Also the
> target action can be tested for with $this->action if you need to test for
> specific cases.
>
>
>
> On Thu, Nov 19, 2009 at 2:22 AM, David Roda  wrote:
> > I'm sorry its late... I didn't even read your post... please ignore my
> > reply! =(
>
> > On Thu, Nov 19, 2009 at 2:21 AM, David Roda  wrote:
>
> >> I think you can use the RequestHandler component for this.
> >>http://book.cakephp.org/view/174/Request-Handling
>
> >> On Wed, Nov 18, 2009 at 10:31 PM, Dr. Loboto  wrote:
>
> >>> There is a hack to render view from other folder: $this->render
> >>> ('..'.DS.'shared'.DS.'json');
>
> >>> On Nov 18, 6:13 pm, ddaffy  wrote:
> >>> > hi!
>
> >>> > i'm using Router::parseExtensions('json') to be able to request data
> >>> > delivered in json format, and i've been wondering if there's a way to
> >>> > change view file that will be used to render data?
>
> >>> > if action test from Examples controller ( /examples/test ) is
> >>> > requested, default view (app/views/examples/test.ctp) is rendered with
> >>> > default layout (app/views/layouts/default.ctp).
>
> >>> > if /examples/test.json is requested app/views/examples/json/test.ctp
> >>> > is rendered with app/views/layouts/json/default.ctp layout.
>
> >>> > because i use unified way for passing variables to view, i don't need
> >>> > every action to have different view for json extension (app/views/
> >>> > examples/json/test1.ctp, app/views/examples/json/test2.ctp...), and i
> >>> > would like to use e.g. app/views/shared/json.ctp. i know how to
> >>> > achieve this for single action, but i need a way to do this globally
> >>> > (in AppController).
>
> >>> > what i tried:
>
> >>> > funciton beforeRender() {
> >>> >         if ($this->RequestHandler->ext == 'json') {
> >>> >             $this->viewPath = 'shared';
> >>> >         }
>
> >>> > }
>
> >>> > results in rendering app/views/shared/.ctp
>
> >>> > funciton beforeRender() {
> >>> >         if ($this->RequestHandler->ext == 'json') {
> >>> >             $this->render('/shared/json');
> >>> >             // or: $this->render('shared/json');
> >>> >             // or: $this->render(null, null, '/shared/json');
> >>> >             // or variations..
> >>> >         }
>
> >>> > }
>
> >>> > result is empty.
>
> >>> > also i saw solution with creating new view class that will override
> >>> > render function and customising it, but it sounds like overkill to
> >>> > me..
>
> >>> > ideal solution in addition to setting $viewPath ($this->viewPath =
> >>> > 'shared') would be to change name of view file that will be requested
> >>> > for rendering, but haven't found a way to do that.
>
> >>> > any ideas would be appreciated.
> >>> > thanks. :)
>
> >>> --
>
> >>> You received this message because you are subscribed to the Google Groups
> >>> "CakePHP" group.
> >>> To post to this group, send email to cake-...@googlegroups.com.
> >>> To unsubscribe from this group, send email to
> >>> cake-php+unsubscr...@googlegroups.com >>>  om>
> >>> .
> >>> For more options, visit this group at
> >>>http://groups.google.com/group/cake-php?hl=.

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.




Re: Contain Question

2009-11-22 Thread gaga
Where you set Profile fields include 'Profile.user_id'.

On Nov 21, 5:47 am, Dave  wrote:
> Wondering why when I specify fields in this contain for User I cant
> get and of the related Profile fields?
>
> If i remove 'fields' from the User it pulls all User fields and then I
> get my Profile fields but I dont want all my User fields, just the few
> i need. What am I doing wrong here?
>
> public function getUser($auth_id)
>         //this fetches basic info for the profile view/index
>         {
>                 $params = array(
>                'conditions' => array(
>                                 'User.id' => $auth_id),
>                         'fields' => array(
>                                 'User.firstname',
>                                 'User.lastname',
>                                 'User.username',
>                                 'User.email',
>                                 'User.slug',
>                                 'User.id',
>                                 'User.reset',
>                                 'User.confirm_code'),
>                         'contain' => array(
>                                 'Profile' => array(
>                                         'fields' => array(
>                                                 'Profile.id',
>                                                 'Profile.email';
>
>                 $q = $this->find('first', $params);
>               return $q;
>         }

--

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-...@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=.