PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.smarty.general > Smarty book published & available
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Smarty book published & available

Réponse
 
LinkBack Outils de la discussion
Vieux 28/04/2006, 20h46   #1 (permalink)
Joao Prado Maia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Smarty book published & available

Hi,

I just wanted to follow-up from a message I sent last month about the
Smarty book. It was finally published this week after a few unexpected
delays, and it is also available as an eBook.

For more information:

http://www.packtpub.com/smarty/book

There's free shipping available directly from Packt Publishing to the US,
UK, Europe, Australia and New Zealand.

Go Smarty!

--Joao
  Réponse avec citation
Vieux 29/04/2006, 16h16   #2 (permalink)
Jochem Maas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Smarty book published & available

first off - congrats! no doubt it will to give Smarty
(a more|an even more) professional 'presence' :-)

secondly could you indicate how much detail the book contains on Smarty
caching? I ask because I have some very dynamic sites (with custom
plugins that retrieve their own data, multilanguage and heavy 'scriptside'
logic) that could do with [partial] caching but so far I have been unable
to figure out how to implement it without causing the output/dynamic-data
requirements of said sites to be broken - a book that detailed extreme/complex
smarty caching implementation might be just what I need.

rgds,
Jochem.

Joao Prado Maia wrote:
> Hi,
>
> I just wanted to follow-up from a message I sent last month about the
> Smarty book. It was finally published this week after a few unexpected
> delays, and it is also available as an eBook.
>
> For more information:
>
> http://www.packtpub.com/smarty/book
>
> There's free shipping available directly from Packt Publishing to the
> US, UK, Europe, Australia and New Zealand.
>
> Go Smarty!
>
> --Joao
>

  Réponse avec citation
Vieux 01/05/2006, 22h47   #3 (permalink)
Joao Prado Maia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Smarty book published & available

Jochem,

> first off - congrats! no doubt it will to give Smarty
> (a more|an even more) professional 'presence' :-)
>


Thanks! I'm glad that the book is finally published and available to the
public.


> secondly could you indicate how much detail the book contains on Smarty
> caching? I ask because I have some very dynamic sites (with custom
> plugins that retrieve their own data, multilanguage and heavy 'scriptside'
> logic) that could do with [partial] caching but so far I have been unable
> to figure out how to implement it without causing the output/dynamic-data
> requirements of said sites to be broken - a book that detailed
> extreme/complex
> smarty caching implementation might be just what I need.
>


I guess it depends on what "extreme/complex smarty caching" means. I wrote
the chapter on caching and there is definetely a lot of content on
conditional caching as well as other features, but it still doesn't matter
much if I don't know exactly what you mean.

--Joao
  Réponse avec citation
Vieux 02/05/2006, 00h52   #4 (permalink)
Jochem Maas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Smarty book published & available

Joao Prado Maia wrote:
> Jochem,
>
>> first off - congrats! no doubt it will to give Smarty
>> (a more|an even more) professional 'presence' :-)
>>

>
> Thanks! I'm glad that the book is finally published and available to the
> public.
>
>
>> secondly could you indicate how much detail the book contains on Smarty
>> caching? I ask because I have some very dynamic sites (with custom
>> plugins that retrieve their own data, multilanguage and heavy
>> 'scriptside'
>> logic) that could do with [partial] caching but so far I have been unable
>> to figure out how to implement it without causing the output/dynamic-data
>> requirements of said sites to be broken - a book that detailed
>> extreme/complex
>> smarty caching implementation might be just what I need.
>>

>
> I guess it depends on what "extreme/complex smarty caching" means. I
> wrote the chapter on caching and there is definetely a lot of content on
> conditional caching as well as other features, but it still doesn't
> matter much if I don't know exactly what you mean.


caching groups. (does that even exist or am I confused?)
[complex] conditional caching.
caching pages where parts of the page needs to stay completely
dynamic.

It's difficult to describe what I mean because of the fact that
I don't grok the smarty cache functionality - bit of a chicken 'n' egg
problem - although what you mention sounds like it could do me some good
to read....

thanks for the feedback.

>
> --Joao
>

  Réponse avec citation
Vieux 02/05/2006, 02h22   #5 (permalink)
Joao Prado Maia
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Smarty book published & available

Jochem,

> caching groups. (does that even exist or am I confused?)
> [complex] conditional caching.
> caching pages where parts of the page needs to stay completely
> dynamic.
>


They do exist and yes, we do cover them on the book. Caching portions of
pages is also covered, and so is conditional caching.

--Joao
  Réponse avec citation
Vieux 02/05/2006, 16h17   #6 (permalink)
Jochem Maas
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Smarty book published & available

I hit send too soon by mistake!

Monte Ohrt wrote:
> Just a reminder, there is a wonderful book written long ago that covers
> Smarty caching. It's called the manual, and it's full of explanations
> and examples
>
> http://smarty.php.net/manual/en/caching.php
>
> Not to mention tons of threads in the forums and wiki pages re-iterating
> this information in detail. I'm sure the new book has useful information
> too, but I'm curious, what is left out that creates this chicken-egg
> delima?


the fact that I don't understand the manuals in so far as the concepts/functionality
of compiling/caching. - or at least I don't see how I can extrapolate the
examples to a level of complexity where I can implement the functionality into
my 'system'.

for instance there are a few lines of code on this page:

http://smarty.php.net/manual/en/cach...ple.caches.php

if(!$smarty->is_cached('index.tpl',$my_cache_id)) {
// No cache available, do variable assignments here.
$contents = get_database_contents();
$smarty->assign($contents);
}

but I have data coming from various sources - injected into the *templates*
(which are often nested) at various places (using various subclasses and
delegate classes for/of the Smarty class) on top of which there are various
a load of plugin functions that retrieve data all on their own (no input
fom the calling scripts) - and pretty much all of this is conditional based on
reuqest and/or session variables. oh and there are quite alot of places where
certain bits of content must be completely dynamic (recalculated on each request
- on a per user basis) even when the gross of the page could actually be cached
because it doesn't change on every request.... lastly I like my caching functionality
to be completely generic so that it's reusable accross all the sites that the
codebase in question is used on (a number of 'big' clients) and the implementing it
on each site doesn't require reams of additional code in my frontend|page scripts.

now just writing that made my head spin ;-)

hopefully you see that it's not your docs at fault so much as I have got a
rather complex codebase and I'm finding it:

a, hard to fully understand the compiling/caching paradigm in smarty per se

and

b, harder still to take the examples in the docs and extrapolate the concepts
into a design for flexible,generic production quality caching mechanism which
i can actually implement (and would work: in terms of the clients' requirements
for dynamic content - i.e. that 'truely' dynamic stuff doesn't get cached, etc).

regards,
Jochem.


>
> Monte
>
> Jochem Maas wrote:
>
>>
>> caching groups. (does that even exist or am I confused?)
>> [complex] conditional caching.
>> caching pages where parts of the page needs to stay completely
>> dynamic.
>>
>> It's difficult to describe what I mean because of the fact that
>> I don't grok the smarty cache functionality - bit of a chicken 'n' egg
>> problem - although what you mention sounds like it could do me some good
>> to read....
>>
>> thanks for the feedback.
>>

>

  Réponse avec citation
Vieux 02/05/2006, 16h34   #7 (permalink)
messju mohr
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Smarty book published & available

On Tue, May 02, 2006 at 05:17:11PM +0200, Jochem Maas wrote:
[...]
>
> hopefully you see that it's not your docs at fault so much as I have got a
> rather complex codebase and I'm finding it:
>
> a, hard to fully understand the compiling/caching paradigm in smarty per se
>
> and
>
> b, harder still to take the examples in the docs and extrapolate the
> concepts
> into a design for flexible,generic production quality caching mechanism
> which
> i can actually implement (and would work: in terms of the clients'
> requirements
> for dynamic content - i.e. that 'truely' dynamic stuff doesn't get cached,
> etc).


my experience with smarty's caching is, that it's

a, works best if the whole system is built with caching in mind, and
built around smarty's caching mechanisms.

and that you can

b, use any caching with smarty that you like: just leave smarty's
caching off, and fetch the cached contents with your cache logic and
assign them to template variables which are displayed templates.

> regards,
> Jochem.

  Réponse avec citation
Vieux 02/05/2006, 19h02   #8 (permalink)
DC
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [SMARTY] Smarty book published & available

Here's a few tips from my learning curve with caching:

http://smarty.incutio.com/?page=CacheAndCompile

and a thread from 18 months ago that talks to what messju mentioned
about creating your own caching logic:

--------------------------------------------------
>
>>>> i have a typical website serving left menu block, top block,

center block...
>>>> etc.
>>>>
>>>> i currently use smarty include tags to pull in these other blocks

to a main
>>>> index template.
>>>>
>>>> i have just realized that the data output from include tags is

cached along
>>>> with the index page's cache - there seems to be no way to keep the

include
>>>> tags dynamic. i want to be able to have each block be independent -
>>>> specifically the center block should be able to have new data

while the left
>>>> menu block still build from cache.
>>>>
>>>> what is the best approach to this problem?

>
>>
>> Do you need to be caching at all? If not, turn off caching, and you
>> should should be okay.



yes, i need caching to deal with some database speed issues. that is
the primary reason i use smarty. that, and the way it s me keep HTML out
of my PHP code.


>> Alternatively...
>>
>> I would create a page template that has placeholder variables for the
>> various content blocks, and then templates for each type of content
>> block. Then, in your script, grab content, pass it to the appropriate
>> content block's template, and use the fetch() method to grab the
>> compiled template contents into a variable. Then pass these variables to
>> the main page template.



so i should use fetch() and pass the returned text to a template variable
placed directly in the index template? if i get you right, fetch() in my PHP
code can take the place of an include tag AND i get cache control over it?
cool. i'll give it a try.

i assume that in this technique, i can no longer cache the index template's
output, but should feed it out 'raw' each request. am i correct in that
assumption? if i left the index template caching in place smarty would just
use the final rendered output text from the display() call and ignore the
fresh/uncached text fetched into template variables. should i turn off
caching just before calling display() as you do in the code below?


>> Using this system, you could turn caching on and off within your script
>> based on the content type.
>>
>> As an example, if $content_blocks contains an array of various content
>> block objects, then:
>>
>> foreach ($content_blocks as $block) {
>> // $block->cache indicates whether or not to cache the block
>> if ($block->cache) {
>> $smarty->caching = 1;
>> } else {
>> $smarty->caching = 0;
>> }
>>
>> // do some processing, assign some variables...
>>
>> // $block->template_file is the name of the block's template
>> // file
>> $block_content = $smarty->fetch($block->template_file);
>>
>> // $block->template_var is the name of the Smarty variable into
>> // which the blocks content will be placed in the main page
>> // template
>> $smarty_page->assign($block->template_var, $block_content);
>> }
>>
>> // Process the main page's content...
>>
>> // Now display the main page
>> $smarty->display('page_template.tpl');



Oh this looks super! I like the idea of organizing my blocks into objects!
Thanks for the tip.
-----------------------------------------------------------

I hope that that s! It took a long time for me to fully understand
the caching system in Smarty - take your time.

Oh yeah, and don't forget $smarty->caching=2; to get non-expiring caches
which is the only way to properly control them. The default is to expire
in 1 hour!

<minorrant>I don't really understand why the default is to expire
caches, but that's the way it is. To me, expiring caches is a
specialized use of caching that should be the result of a request, not
the default. If you turn on caching, it should just turn on and stay on
- not turn off in an hour. But, then again, I'm not the one who built
smarty and it is easy enough to change it. But, it sure stumped me for a
few days until i read the fine print in the manual.</minorrant>

dan

messju mohr had written:
> On Tue, May 02, 2006 at 05:17:11PM +0200, Jochem Maas wrote:
> [...]
>
>>hopefully you see that it's not your docs at fault so much as I have got a
>>rather complex codebase and I'm finding it:
>>
>>a, hard to fully understand the compiling/caching paradigm in smarty per se
>>
>>and
>>
>>b, harder still to take the examples in the docs and extrapolate the
>>concepts
>>into a design for flexible,generic production quality caching mechanism
>>which
>>i can actually implement (and would work: in terms of the clients'
>>requirements
>>for dynamic content - i.e. that 'truely' dynamic stuff doesn't get cached,
>>etc).

>
>
> my experience with smarty's caching is, that it's
>
> a, works best if the whole system is built with caching in mind, and
> built around smarty's caching mechanisms.
>
> and that you can
>
> b, use any caching with smarty that you like: just leave smarty's
> caching off, and fetch the cached contents with your cache logic and
> assign them to template variables which are displayed templates.
>
>
>>regards,
>>Jochem.

>
>

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 01h54.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,18068 seconds with 16 queries