I want to implement the feature for admins to set custom templates. Like they can place themes or templates in a particular folder relative to the home folder.
Each theme may have a folder and some config or preview for example(optional).
1) First I need to figure out how to set custom templates dir for an app.
2) Then I can probably do listdir and get all the folders and then give the admin an option to select the dir.
3) A setting list to specify additonal template folders by users.
1 is the problem.
The main question I want answer for is how to set custom template dir which can be modified anytime.
I found out that askbot (the SO clone) implements this kinda theming where you can place themes in subfolders a folder and the admin can select the folder which he/she wants the templates.
I am new to Django. I guess you can do it using jinja templating.
http://jinja.pocoo.org/
Add a common styling to one html page(base.html)
and then extend the base html to whichever pages u want using extends-- check out template inheritance in the above link
Also you can get some cool templates in bootstrap.. checkout their template section. https://www.w3schools.com/bootstrap/bootstrap_templates.asp
Good luck!
Related
I'm a beginner in django/oscar.
I created my virtual env and I followed the procedure for create a new django project.
Now, I want to personalize my page without to fork the repo.I want only extend oscar's template (for example change background, add a new navbar ecc).
I solved the my problem.You have to copy the folder myenv/lib/site_package/oscar/..etc../template and paste her in your project's root.Obviously you have to change the path in settings.py in the TEMPLATE's section.
I'm not sure, Django CMS Blog is complete app or foundation for self-extending ? I can see one huge logical mistake - inside one app config, I can't easy change template - for list, detail, archive and item - they are strict and hardcoded in plugin code.
Is there any way to customize it without hacking the app/writing tons of custom plugins ?
I need several versions for each template - especially for blog_item.html, blog_detail.html and blog_archive.html.
I want to use plugin feature from Django CMS and don't want to hardcode whole layout in template include logic because this is broking MVC logic (!).
OK, I know, I can include my custom subtemplate blog_item in list template with instance varibles, but I totaly can't imagine, how to do it in several places - front page, list page, post page etc BUT using regular Django CMS plugin features - I have static placeholders and tpl blocks - but there still is one template for item, inside app code.
I understand (less/more) Django template inheritance, but this case is more complicated than simple inheritance between templates.
At frontpage I want different list of latest posts - one template
at category list - different layout - so next template,
inside post - detail_view - need to be customized in other way.
Can somebody guide me, how to achieve this ? Custom plugin for each layout case or something ? A bunch of IF statement in template, dependend from contex is ridiculous..
I have replaced templates set, for app config - configured templates prefix, and whole folder with articles/*.html files. But changing item subtemplate cause change layout part in many places in the same time. This is main problem. Each using "latest posts" plugin, use same template - and I can't set template files for each plugin instance.
After some tests and talks, there is no nice way to replace templates, except extending plugin class and write own better version of plugin...
I created my own template named ibtheme, then I copy woocommerce folder from Woocommerce plugin to my template. But when I click on a product on frontpage, I see that it call the template files in plugins/woocommerce/templates/single-product, not from ibtheme/woocommerce/templates/single-product/
Please help me to override product page template!
Thanks advance!
As you have already discovered, you can edit the template files in an upgrade safe way through overrides. Simply copy it into a directory within your theme named /woocommerce, keeping the same file structure.
Example: To overide the price display template, copy: wp-content/plugins/woocommerce/templates/single-product/price.php to wp-content/themes/ibtheme/woocommerce/single-product/price.php
You can read the full documentation for WooCommerce theming at Template Structure + overriding templates via a theme
I would suggest that only copy/override the specific templates that you plan to modify. I've had to go through every single template to repair a broken theme/site after a major WooCommerce upgrade, so trust me, this will make it easier to upgrade WooCommerce in the future.
I could not find any info on overriding a Joomla plugin in my template.
Some forums claimed there was no plugin override, and the Joomla documentation (being the menacing forest that it is) either has nothing on the subject, or the page is hard to find.
So how can we override the output of a Joomla plugin in the same was we override the output of com_content or mod_contact?
I have found a way to do this:
Navigate to <joomla_homefolder>/administrator/language/<your_language>/
Search for the plugin's corresponding language file.
Copy the file name, EXCLUDING the language prefix (ie en-GB.) and the .ini suffix.
In your template create a folder named html (a common practice for template overrides).
In the html folder create a subfolder and name with the language file name as you copied it in step 3.
Navigate to the tmpl subfolder in the plugin's path: <joomla_homefolder>/plugins/<plugin_type>/<plugin_name>/tmpl
Copy the view file you wish to override into the folder you've created in step 5.
Modify the copied file to override the plugins output.
For example -
To change the page navigation buttons - modify the output of <joomla_homefolder>/plugins/content/pagenavigation:
Go into <joomla_homefolder>/administrator/language/en-GB/ and find the file named en-GB.plg_content_pagenavigation.ini.
From the filename copy only plg_content_pagenavigation.
Create a folder named html (If it does not exist already) in your theme, inside it create a subfolder and name it plg_content_pagenavigation.
Copy the view file <joomla_homefolder>/plugins/content/pagenavigation/tmpl/default.php into the plg_content_pagenavigation folder you just created.
Modify the file.
Note: I have tried it only with Joomla 3.1.
The method may not work with some plugins.
Good Luck.
In joomla 3 you can override plugins output only, that's why the origin plugin must be implemented with a tmpl.
The naming convention of the folder in you [template]/html is
plg_[type*]_[pluginElement]
Template overridden native joomla plugins is only the pagenavigation.
type* : obviously there's no sense to be other than content but if it's custom plugin no one can stop you.
On a Joomla 3.1 install, I am using the Simple Image Gallery plugin and I felt the need to override it in order to add extra functionality to each thumbnail of the gallery.
I copied all of the contents of <joomla_homefolder>/plugins/content/jw_sig/jw_sig/tmpl/ into the folder <joomla_homefolder>/templates/protostar/html/jw_sig/ and I was then able to modify both the default.php file for output modifications, and the accompanying template.css file for styling modifications. This successfully overrides the plugin's output without risking issues during future updates.
Of course, this will not work with all plugins, but it offers another alternative if you have a plugin that was nice enough to be developed with a tmpl folder.
No you can't override the same way because there is not tmpl folder because plugins really should not be rendering though of course a lot do. You probably need to clone the plugin and make a the layout your want possibly using a jlayout to make it easier to manage.
Elin's answer is not quite correct for Joomla 2.5-3.x. Some plugins do render screen output and have /tmpl folders that you may be able to override. See http://docs.joomla.org/Layout_Overrides_in_Joomla
In some cases you may need to create alternative views within the plugin /tmpl folder. For example, some of the simple, newer custom content components that use JForms let you add fields to com_content articles and select a view template for each field. Then overrides for com_content are generated dynamically to display the custom fields. Each field type can be displayed in the component area through plugins, or in a module, or within the template code, but it will use the /tmpl file you selected for the field in the CCK component. If there is a way to override the different field views from within the template folder, it must require an arcane menu structure I haven't been able to discover.
The Django documentation states the following clearly:
Not every template in contrib\admin\templates\admin may be overridden per app or per model.
It then lists the ones that can, and base.html, base_site.html and index.html – the ones I'm interested in – are not among those listed. They can be overridden per-project, but not per-app.
My question is: is there a way around this that doesn't involve editing the code inside django.contrib.admin? I'm willing to consider some monkeypatching solutions :-). I really want my app to have custom versions of those three files inside its templates directory, and have each project that uses the app to use those.
The reason I'm interested is that I'm creating a large, reusable app with a heavily customized admin interface, and per-project overrides of the "core" templates aren't the best solution, since I'd have to copy the custom templates to the template directory of each project that the app gets used in. Releasing new versions of the app with new modifications to those core templates would mean re-copying everything to the affected projects. Ugh.
I understand the reasoning behind the decision to only make a select few templates overridable per-app; after all, if overriding them all was possible, which app's overridden admin would take precedence?
But in my case, the app will be the "centerpiece" of several client projects, with other apps in those projects merely being in a supporting role.
CSS-based customization of the existing templates only gets you so far, and I'm hesitant to rely on JavaScript DOM manipulation solutions unless absolutely necessary.
One solution that comes to mind is to place the custom base.html etc. templates inside appname/templates/admin/ and then symlink them to the project's templates folder. That way any updates to the app will automatically take effect on the project level.
Symlinking is probably my method of choice if nothing better is suggested, but I'd like to hear if anyone has a nicer solution.
As I see your goal is to override templates for entire project, not for app or for model, but you don't want to put templates in project's template folder.
So you should just create 'base.html', etc. in 'your_app/templates/admin' folder.
Next you have to tell django that templates should be loaded not only from project's template folder, but also from your app's folder.
This can be done using TEMPLATES_DIR variable in settings.py file, smth. like that:
TEMPLATE_DIRS = (
os.path.join(PROJECT_PATH, 'templates'),
os.path.join(PROJECT_PATH, 'my_app','templates'),
)