Welcome Guest, Not a member yet? Register   Sign In
Smarty Plugin access to database

Hello Code Igniters,

I've been following the progress of CI, for a while, and now I've decided to use CI and Smarty on a real project.

I have Smarty wired-in just dandy, and I can push data to a Smarty template from a controller with template->assign. Caching is working great too.

Now I'm starting to build smarty plugins to pull data from smarty "tags", sorta like expression engine does it (but with it's own template engine). I have that part working too on non-db data , as described in the Smarty manual under "componetized templates".

Just one piece is missing: I need to be able to access the database in these Smarty plugin functions, but it seems you have to be an instance of a controller or a view to load the database and use these features. I really don't want to use another db library or the built-in php functions for mysql. I like the CI database layer.

Maybe one way would be to get a handle on the current controller from within the Smarty plug-in function. Perhaps this would be similar to getting a handle on the CI instance, as discussed in this wiki entry: http://www.codeigniter.com/wiki/Use_URL_...om_Smarty/.

I've read most of the forum entries on Smarty. I tried several things and nothing yet has worked. I think I just don't have a deep enough understanding of PHP OO to get this working.

Does anyone have any suggestions?



Theme © iAndrew 2016 - Forum software by © MyBB