Re: Importing a helper

2008-06-24 Thread francky06l

I usually do :

if(!isset($this->helpers['Time']))
$this->helpers[] = 'Time';

Seems a lot of concern about performances (even if this checked by
cake, that avoid the cake checking) ..
My 2 (maybe 1) cents..

On Jun 24, 11:13 pm, "Federico Rinaldi" <[EMAIL PROTECTED]>
wrote:
> It actually works but the Helper's callbacks are not called so is only
> viable if you don't need them.
>
> On Thu, Jun 19, 2008 at 9:48 AM, Chris Hartjes <[EMAIL PROTECTED]> wrote:
>
> > On Wed, Jun 18, 2008 at 9:15 PM, Turnquist, Jonah <[EMAIL PROTECTED]>
> > wrote:
>
> > > I do not understand I did not give an answer I gave another question,
> > > the question mark indicating that.  Does the RAM not effect
> > > performance?  also, it does not matter if the database is slower than
> > > the loading of the helper.  That does not mean I should not optimize
> > > other areas besides the database.  Also I do not want the Time helper
> > > loaded into all the actions because they are not used there, and that
> > > is bad organization, and organization is what cakePHP is about,
> > > right?  So why not try to be organized.
>
> > My point was that there are probably other things that are more likely
> > to affect the performance of your application than loading the Time
> > helper for every action in a controller.
>
> > And how can you say that "it does not matter if the database is slower
> > than the loading of the helper"?!?  Of course it matters.  How can
> > someone who is so concerned about "speed" ignore such a thing as the
> > "speed" at which you get data from a database?
>
> > In the interest of avoiding further douchebaggery, I will agree to
> > disagree with you on the topic of premature optimization.  Glad that
> > Mr. Snook found the answer for you.  My solution was missing a step,
> > but I have no idea if it was going to work:
>
> > App::Import('Helper', 'Time');
> > $timeHelper = new TimeHelper();
> > $this->set('timeHelper', $timeHelper);
>
> > and then in your view you could reference the helper via $timeHelper.
>
> > Like I said, it *looks* good but no idea if it would work.
>
> > --
> > Chris Hartjes
> > Internet Loudmouth
> > Motto for 2008: "Moving from herding elephants to handling snakes..."
> > @TheKeyBoard:http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-24 Thread Federico Rinaldi
It actually works but the Helper's callbacks are not called so is only
viable if you don't need them.

On Thu, Jun 19, 2008 at 9:48 AM, Chris Hartjes <[EMAIL PROTECTED]> wrote:

>
> On Wed, Jun 18, 2008 at 9:15 PM, Turnquist, Jonah <[EMAIL PROTECTED]>
> wrote:
> >
> > I do not understand I did not give an answer I gave another question,
> > the question mark indicating that.  Does the RAM not effect
> > performance?  also, it does not matter if the database is slower than
> > the loading of the helper.  That does not mean I should not optimize
> > other areas besides the database.  Also I do not want the Time helper
> > loaded into all the actions because they are not used there, and that
> > is bad organization, and organization is what cakePHP is about,
> > right?  So why not try to be organized.
>
> My point was that there are probably other things that are more likely
> to affect the performance of your application than loading the Time
> helper for every action in a controller.
>
> And how can you say that "it does not matter if the database is slower
> than the loading of the helper"?!?  Of course it matters.  How can
> someone who is so concerned about "speed" ignore such a thing as the
> "speed" at which you get data from a database?
>
> In the interest of avoiding further douchebaggery, I will agree to
> disagree with you on the topic of premature optimization.  Glad that
> Mr. Snook found the answer for you.  My solution was missing a step,
> but I have no idea if it was going to work:
>
> App::Import('Helper', 'Time');
> $timeHelper = new TimeHelper();
> $this->set('timeHelper', $timeHelper);
>
> and then in your view you could reference the helper via $timeHelper.
>
> Like I said, it *looks* good but no idea if it would work.
>
> --
> Chris Hartjes
> Internet Loudmouth
> Motto for 2008: "Moving from herding elephants to handling snakes..."
> @TheKeyBoard: http://www.littlehart.net/atthekeyboard
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-19 Thread Turnquist, Jonah

Ok, thanks man.  I will try out your method again when I get back from
weight training class.

Jonah

On Jun 19, 5:48 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 18, 2008 at 9:15 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>
> > I do not understand I did not give an answer I gave another question,
> > the question mark indicating that.  Does the RAM not effect
> > performance?  also, it does not matter if the database is slower than
> > the loading of the helper.  That does not mean I should not optimize
> > other areas besides the database.  Also I do not want the Time helper
> > loaded into all the actions because they are not used there, and that
> > is bad organization, and organization is what cakePHP is about,
> > right?  So why not try to be organized.
>
> My point was that there are probably other things that are more likely
> to affect the performance of your application than loading the Time
> helper for every action in a controller.
>
> And how can you say that "it does not matter if the database is slower
> than the loading of the helper"?!?  Of course it matters.  How can
> someone who is so concerned about "speed" ignore such a thing as the
> "speed" at which you get data from a database?
>
> In the interest of avoiding further douchebaggery, I will agree to
> disagree with you on the topic of premature optimization.  Glad that
> Mr. Snook found the answer for you.  My solution was missing a step,
> but I have no idea if it was going to work:
>
> App::Import('Helper', 'Time');
> $timeHelper = new TimeHelper();
> $this->set('timeHelper', $timeHelper);
>
> and then in your view you could reference the helper via $timeHelper.
>
> Like I said, it *looks* good but no idea if it would work.
>
> --
> Chris Hartjes
> Internet Loudmouth
> Motto for 2008: "Moving from herding elephants to handling snakes..."
> @TheKeyBoard:http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-19 Thread Chris Hartjes

On Wed, Jun 18, 2008 at 9:15 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>
> I do not understand I did not give an answer I gave another question,
> the question mark indicating that.  Does the RAM not effect
> performance?  also, it does not matter if the database is slower than
> the loading of the helper.  That does not mean I should not optimize
> other areas besides the database.  Also I do not want the Time helper
> loaded into all the actions because they are not used there, and that
> is bad organization, and organization is what cakePHP is about,
> right?  So why not try to be organized.

My point was that there are probably other things that are more likely
to affect the performance of your application than loading the Time
helper for every action in a controller.

And how can you say that "it does not matter if the database is slower
than the loading of the helper"?!?  Of course it matters.  How can
someone who is so concerned about "speed" ignore such a thing as the
"speed" at which you get data from a database?

In the interest of avoiding further douchebaggery, I will agree to
disagree with you on the topic of premature optimization.  Glad that
Mr. Snook found the answer for you.  My solution was missing a step,
but I have no idea if it was going to work:

App::Import('Helper', 'Time');
$timeHelper = new TimeHelper();
$this->set('timeHelper', $timeHelper);

and then in your view you could reference the helper via $timeHelper.

Like I said, it *looks* good but no idea if it would work.

-- 
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-18 Thread Turnquist, Jonah

Haha, lol nice,

On Jun 18, 6:32 pm, "Jonathan Snook" <[EMAIL PROTECTED]> wrote:
> > Hey that works.  Thanks.  I'm surprised this is not documented though.
>
> There, now it is:http://manual.cakephp.org/view/99/introduction
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-18 Thread Jonathan Snook

> Hey that works.  Thanks.  I'm surprised this is not documented though.

There, now it is: http://manual.cakephp.org/view/99/introduction

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-18 Thread Turnquist, Jonah


On Jun 18, 5:41 pm, "Jonathan Snook" <[EMAIL PROTECTED]> wrote:
> While I haven't tried it, maybe give this a go in your action:
>
> function myaction(){
>
> $this->helpers[] = 'Time';
>
> }
>
> (I'm not entirely sure when helpers are instantiated but that seems
> like a viable solution.


Hey that works.  Thanks.  I'm surprised this is not documented though.

BTW if anyone else knows any other ways also do tell, as this method
might not work in later versions of cake.

from "Chris Hartjes"
> Your answer shows that you do not understand the question.  It's not
> about RAM, it's about performance.  It's likely that it will take more
> resources to talk to your database than to hold the time helper in
> memory.

I do not understand I did not give an answer I gave another question,
the question mark indicating that.  Does the RAM not effect
performance?  also, it does not matter if the database is slower than
the loading of the helper.  That does not mean I should not optimize
other areas besides the database.  Also I do not want the Time helper
loaded into all the actions because they are not used there, and that
is bad organization, and organization is what cakePHP is about,
right?  So why not try to be organized.

Thanks,
Jonah


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-18 Thread Jonathan Snook

While I haven't tried it, maybe give this a go in your action:

function myaction(){

$this->helpers[] = 'Time';

}

(I'm not entirely sure when helpers are instantiated but that seems
like a viable solution.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-18 Thread Chris Hartjes

On Wed, Jun 18, 2008 at 8:15 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
> If it does not slow it down why don't all the helpers just all get
> loaded automatically?  I mean, the Time helper is 538 lines of code.
> It must slow it down to load that into RAM and deal with it.

Your answer shows that you do not understand the question.  It's not
about RAM, it's about performance.  It's likely that it will take more
resources to talk to your database than to hold the time helper in
memory.

Just my opinion, but others share it.

-- 
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-18 Thread Turnquist, Jonah


> Did you try this in your index controller (assuming you are using 1.2):
>
> App::import('Helper', 'Time');
> $timeHelper = new TimeHelper;

No, I have not tried that.  I am using 1.2.  It still does not work
though. Here's my code:

controller:
class ScriptsController extends AppController {
function index() {
App::import('Helper', 'Time');
$timeHelper = new TimeHelper;
$this->set('scripts', $this->Script->find('all'));
}
[...]

View:
[...]
nice($script['Script']['created']); ?>
[...]

I got this error though:
Notice (8): Undefined variable: timeHelper [APP\views\scripts
\index.ctp, line 31]

> If you seriously think that having the Time helper included when your
> controller is loaded and being available for every action will reduce
> the speed of the application in any appreciable way, I doubt your
> ability to determine the choke points of an application.

If it does not slow it down why don't all the helpers just all get
loaded automatically?  I mean, the Time helper is 538 lines of code.
It must slow it down to load that into RAM and deal with it.

Thanks,
Jonah
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Importing a helper

2008-06-18 Thread Chris Hartjes

On Wed, Jun 18, 2008 at 7:50 PM, Turnquist, Jonah <[EMAIL PROTECTED]> wrote:
>
> But that would include it into all the actions, not just the 'index'
> action which I need.  How do I include it into in index action alone?
> I always worry about speed.  Also, can I include it from the view?
> that would be best, as it is only used in the view.  How do i do this?

If you seriously think that having the Time helper included when your
controller is loaded and being available for every action will reduce
the speed of the application in any appreciable way, I doubt your
ability to determine the choke points of an application.

No, you can't include it from the view either.

Did you try this in your index controller (assuming you are using 1.2):

App::import('Helper', 'Time');
$timeHelper = new TimeHelper;

Hope that helps, and beware of premature optimization.

-- 
Chris Hartjes
Internet Loudmouth
Motto for 2008: "Moving from herding elephants to handling snakes..."
@TheKeyBoard: http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Importing a helper

2008-06-18 Thread Turnquist, Jonah

hello again guys

I grew a question (type: noobQuestion, cakeVersion: 1.2)

I need to include the Time helper in the 'index' action of the
'scripts' controller page.  I understand I can put this in the
controller:

var $helpers = array('Time');

But that would include it into all the actions, not just the 'index'
action which I need.  How do I include it into in index action alone?
I always worry about speed.  Also, can I include it from the view?
that would be best, as it is only used in the view.  How do i do this?

PS don't say I am to lazy to figure it out for myself, I tried.

Thanks,
Jonah
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---