Welcome Guest, Not a member yet? Register   Sign In
Theming your applicaton - How to override view files.
#1

[eluser]jadebot[/eluser]
For example suppose I wanted to code something like Wordpress with CI.
I would need a way to enable theming. To accomplish this, I would guess that a theme plugin would simply contain duplicate-named files for all views.

Enabling the theme would tell the engine to look for the view in the theme first and fetch it there. This way all your controllers would only have to call one view such as 'master' , but the master view could be overwritten by any enabled theme.

It seems CI already does this for things like libraries, plugins, helpers etc.
I.E in the documention it always says 'CI will first look in the application folder for the file and if it does not find it there, it will look in the system ..."

I appreciate any help. Thanks.
#2

[eluser]geshan[/eluser]
if you Want to do this try HMVC (http://codeigniter.com/wiki/Modular_Extensions_-_HMVC) divide your application into Modules and let one module be the "Theme" module. Then use libraries like Ocular (http://ocular.googlecode.com/) and make themes with partial views and themes possible in single folder package. Hope it helps.
#3

[eluser]Adam Griffiths[/eluser]
Take a look at the Template Library (link in my signature). With it you can have multiple themes in multiple folders. You could easily change the theme using the set() function.

It might not be enough for you but I will update it regularly.
#4

[eluser]Colin Williams[/eluser]
You can have a look at the Template library in my signature. It has a cascade-like way of suggesting Views (keeps falling back until it finds a view that exists). And like Adam's Template library, you can dynamically change the main template.

Be sure to look at Adam's library and my own in detail because there are significant differences. One or the other might be exactly what you need, or should at least set you off in a direction of writing your own.
#5

[eluser]jadebot[/eluser]
[quote author="geshan" date="1225717342"]if you Want to do this try HMVC (http://codeigniter.com/wiki/Modular_Extensions_-_HMVC) divide your application into Modules and let one module be the "Theme" module. Then use libraries like Ocular (http://ocular.googlecode.com/) and make themes with partial views and themes possible in single folder package. Hope it helps.[/quote]

Thanks for this recommendation! I must admit it all went over my head the first time i looked at it, but the more work I did in CI the more I was able to get the gist of it. I have since uploaded this mod into my install and I think I finally get it!

Basically it allows a kind of portable instance of of a CI implementation.
For example I was looking into the freakauth package. I got this up and running fine and its a great add on. But if I have HMVC, a better way to integrate freakauth would be to just drop it into a module. Freakauth would/should work in the exact same way right, except its completely portable... is this correct?

I am going to try it right now actually, I was just anxious to reply to this post and thank you for your help.




Theme © iAndrew 2016 - Forum software by © MyBB