Forumlar / Cotonti / General / PHP callbacks, the drawbacks?

foxhound
#1 2013-12-10 12:35

I am using a few (say 10 PHP callbacks) in a list.tpl which creates an output of pages for me which I want to display on top of the list, depending where you are.

But, as you all know an easy way has its downside as well so I was actually curios about the statement made on the page explaining about the PHP callbacks: 
http://www.cotonti.com/docs/ext/themes/cotemplate_advanced

You write: "Putting logic in your template has some drawbacks. Firstly, it's slow if used a lot....... "
But, what is  'a lot" speaking about those callbacks? Is 10 a lot? Or with a lot I should more think of 100's callbacks in a tpl?

Does "a lot" also depend on the kind of callback you are doing?
Like for example I am using one to get a specific date in my title and 10 others to output different data depending on your location on the site, so it wont output all 10 data's at the same time.

Does "a lot" also depend on how active your website is? Meaning if you have 10 pageviews a day you can make 1000 php callbacksin a tpl but if you have 500000 pageviews you should only make 1 php callback in a single tpl?

Does it also depend one in how many different tpl's you actually use them?


I hope to get some more info about this so I know a bit more about the do's and don'ts of the php callbacks :)

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Trustmaster
#2 2013-12-10 16:10

"A lot" is of somewhat the same nature the term "reasonable" is. All factors you mentioned matter. But, to put it short:

  1. 10 callbacks is ok. 100 may slow your site down a bit.
  2. Simple callbacks are ok. Be careful with heavy ones. For example, "pagelist" plugin works as a callback. There are several more plugins which query the database and do lots of stuff but are simply embedded in templates as callbacks. We call such plugins "widgets". Such widgets are "heavy", so it's reasonable to keep just a few of them.
May the Source be with you!
foxhound
#3 2013-12-11 22:48

Ok, thanks for the info Trustmaster. I will make sure to not overdo things and keep an eye on performance :)

<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />