I want to make my web app theme-able. There are 3 ways I researched:
Solution 1:
- application
- views
- theme1
- template files
- theme2
- template files
- admin template
- css
- theme1
- theme2
- js
- theme1
- theme2
- images
- theme1
- theme2
It is working well. However it is not comfortable when placing files in separated folders.
Solution 2
- application
- views
- theme1
- css
- js
- images
- template files
- theme2
- css
- js
- images
- template files
- admin template
And I changed /application/.htaccess to
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
It is also working well, but is it good for security? (i’m not good at .htaccess)
Solution 3
- application
- views
- admin template
- themes
- theme1
- css
- js
- images
- template files
- theme2
- css
- js
- images
- template files
And I changed views path to theme folder in MY_Loader.
It looks like better structure. I have an issue with admin template.
Becuse I want also to place admin template files in folder views as a core system,
I don’t know how to make views load function can see files in both of place.
Could everyone please advice me for the best solutions.
Thanks and Best Regards,
In MY_Loader, I assume you’re extended the view() function to look for the right view in a different location? If that’s the case, why not create a new function in MY_Loader called adminView() or something which is just a copy of the view() function, but it looks for views in the admin location.
In your controller for methods that are calling theme specific files, you would call:
and when you need to call an admin template, you would call: