Welcome Guest, Not a member yet? Register   Sign In
Selective Caching or.. Caching only a part of the output..
#1

[eluser]Unknown[/eluser]
Hey Guys,

I have a question.. I'm battling between using Smarty and using Code-Ignite.. yes I know they're very different but if I use Smarty I obviously won't be using Code-Ignite and vice versa..

Anyway I've read the features list and looked at the caching tutorial and there's one thing I'm missing - how do I cache only a small part of my page?

For example I have a header, footer, menu and content area and I would like to cache anything which isn't related to the members state - say the static footer and the semi-dynamic header (latest news but only changes once or twice a day) but I would not like to cache the menu (with it's "Hello {member_name}" and other member-related data)..

So what I'm asking if there's a way to control cache-ability of only certain views.

Thank you!
- Ben
#2

[eluser]sophistry[/eluser]
ah, a first post.

well, welcome to CI... sit down and stay a while.

there's no need to make CI and Smarty mutually exclusive. you can combine them - smarty is just another library as far as CI is concerned.

CI is a framework with a wickedly fast and not overly-developed code base ( i say that with the utmost praise since fat code means sluggish sites ).

smarty is a template compiler/parsing engine with caching and lots of plugins.

http://ellislab.com/forums/viewthread/44719/ that thread shows one way to integrate smarty into CI. some of the stuff might be a little outdated, but it should get you started.

post with questions. people are pretty ready around here!

in fact a while back, one of the smarty core devs named monte ohrt (CI membername: mohrt) was pretty active around these boards and had suggestions how to integrate smarty; it's pretty straightforward to bring in any library. just do a search on smarty, mohrt, cache, templates.

oh, and, by the way... don't try to use CI cache code out-of-the-box to do what you've described. if you know smarty and its caching system you'll be pretty disappointed in CI - it's lean in the caching dept and you have to use a third party library (see the wiki) to get it up to the tricks you want (head, footer, body part cache). it sounds like you've discovered that already!

smarty is the best third party library choice (IMO) if caching is your primary need, but adopting CI will benefit you for years down the road. there are tons of "testimonial" threads on these boards so i won't bore you with mine, but CI will make you a better programmer - without a doubt.

i started with smarty a few years back, then found CI and now they happily play together. now, instead of starting a web project thinking "how will i set this up in the smarty way?" with CI in my pocket, i think: "wow, all this web framework groundwork is done, let's focus on getting ideas working on the web. oh yeah, i need caching - smarty would be a good tool to pull into this project, oh yeah, i need to send HTML email, ok, there's a core lib, oh, i need to migrate to a different database, alright, there's a core CI abstraction layer, um, i need to get some organization to my code and keep HTML separate from my PHP code, ah, there's the MVC pattern built into the system."

in short, jump in, the water's fine.

TTFN.




Theme © iAndrew 2016 - Forum software by © MyBB