how can I use IntelliJ live edit with django templates? - django

I like the IntelliJ 'live edit' feature but it doesn't work for Django templates because obviously they are just a bunch of variables and its not finding the CSS files. Is there some way of working 'live' on Django templates? (or any other templating system for that matter).
Similarly I tried to use Chrome devtools autosave but it also didn't work, presumably it wants me to open an html file locally (i.e. file://).
And using chrome inspector to edit stuff is a pain because you have to copy and paste your changes - unless I'm missing something?

I am using IntelliJ 12.0.4 Ultimate with the Python plugin (this is more or less equivalent to PyCharm) to work on Django templates. It doesn't look like the Live Edit functionality works as per usual, indeed because the template has to be rendered to HTML first by Django.
One alternative is to assign a keyboard shortcut to the "View | Reload in Browser" menu item.
Another alternative is to use a Chrome plugin such as ChromeReload: You can set this to reload a specific page at a specific interval.

Related

Opencart different .TPL for the Home Page

I have a doubt and not really sure about how is the best approach, I have a client with a website based on opencart with really bad practices on it, for example, all products are manually placed in the home page instead to be using the CMS capabilities of OC, right now the way it works is, if you are using a computer, full browser, the site displays the full version of the site, but if you are using an ipad or iphone/android device then loads the "small" version, both versions are placed manually in the same home.tpl document and they appear/disappear by some CSS. The question is, the client doesn't want to change the way the home page is designed, so instead to be loading that enormity of code is there a way to have a different tpl for the small version? for example a home.tpl version with the code for the full version and home-mobile.tpl for the small one? how this should work? How the system should determine the screen size and point to a TPL or other TPL?
I know it's a weird request but the client is "happy" with how the site looks like and don't want to change the manual code used on the home page.
CSS is the correct way to handle the resizing and restructuring of the same content on different screens. If you want a vastly different homepage for mobile users, with different content, there are a couple of ways to do it:
Detect the browser using JS and redirect to a mobile-only page. This would probably involve copying your current home controller (and template etc.) to a new file, or using a GET variable to switch templates further down the code.
Detect the browser using PHP, and serve the correct template directly in the code. For this you could use a library like this one (untested, just an example) in your home controller, and change the template path as needed at the bottom of the script.
But first I would really try harder to emphasise to your client that he is doing it wrong.

django-tinymce modern theme

I'm having issues getting the modern theme to work with django-tinymce. Both the simple and the advanced themes render correctly, but when I switch to the modern theme nothing renders and I get a 404 error for /static/tiny_mce/themes/modern/editor_template.js in the console
I am attempting to do all of this in the django admin. The error is coming from /static/tiny_mce/tiny_mce.js which is interesting because I don't have anything installed in that directory. I'm using /static/js/tinymce as my TINYMCE_JS_ROOT in settings.py. When switching between simple and advanced theme, everything works correctly.
I've tried to copy a version of editor_template.js in the exact location it's looking, but I still get the 404. It's like it wipes out /static/tiny_mce if it exists and replaces it with something, but I can't figure out how/where it's getting that from.
I'm using an install of TinyMCE 4.1.3 from http://www.tinymce.com/download/download.php and django 1.6.5
I've been struggling with TinyMCE recently, as well. I'm using TinyMCE v4 and Django 1.6. I went down the django-tinymce/django-flatpages-tinymce route because I had these working on another project. Some how it wasn't working for this new project. I did some research and decided to just go straight TinyMCE, no Django applications (eg, no django-tinymce or django-flatpages-tinymce).
This method cuts down on all configuration in Django, and it can be completely handled within the tinymce.init call. I found this much easier than dealing with Django's settings files, overriding models, etc. Just simply find the template you want TinyMCE to spice up and add the init call there.
The example here for full featured example really helped me:
http://www.tinymce.com/tryit/full.php
This use the modern theme...
I simply added this to whichever change_form.html template for whatever model I was needing the rich editor. For instance for flatpages:
admin/flatpages/flatpage/change_form.html
Or custom model in app:
admin/custom_app/model_name/change_form.html
I know this is exactly an answer to your question, but I think it's worth thinking about and might help you ultimately get what you need.
Also, I should note, it looks like only modern theme is available for TinyMCE v4:
http://www.tinymce.com/wiki.php/Tutorial:Migration_guide_from_3.x

Dreamweaver type templates in Aptana

I am designing a very small website using basic HTML. I usually use a CMS but it has been a while since I did just HTML files, I was wondering if there was some sort templating where you can have like areas like a "Master template" and when a section is changed or added to the rest of the HTML pages that have those sections change with it. Like a common header and footer so I don't have to make the changes in each page if I need to make a change to an element.
I am using AptanaStudio 3 and was wondering if there was a feature like that as there is in Dreamweaver. I don't have Dreamweaver installed on my new computer, so taht is not an option.
Thanks in advance
You can try server-side includes (SSI): http://www.htmlgoodies.com/beyond/webmaster/article.php/3473341/SSI-The-Include-Command.htm

Opencart module development - Inject javascript/html code in some pages

I'm a beginner on Opencart and just started developing a module for Opencart which it must inject some lines of javascript and html code in these pages:
- Cart Page
- Product Page
- Confirmation Order Page
- Register form page
The official documentation doesn't have informations about how can i do that, I've tried to find a good documentation about OpenCart but I didn't find anything.
I need help. How can I do that?
Diggin necro topics;) :
The easiest way i think:
upload/catalog/view/theme/[themename]/template/product/product.tpl - here you can add your custom html for product page
[your theme name, you shouldnt overwrite default theme because it can cause damage after update]
It depends on where you're trying to insert the HTML/JavaScript.
Doing things the proper way in OpenCart, you're limited to the column-left, column-right, content-top, and content-bottom positions.
The files you'll need to create are:
admin/controller/module/mymodule.php
admin/language/english/module/mymodule.php
admin/view/template/module/mymodule.tpl
catalog/controller/module/mymodule.php
catalog/language/module/mymodule.php
catalog/view/theme/default/module/mymodule.php
To learn how to do this the first time, it's easiest to replicate an existing stock OpenCart module (preferably a simple one, such as information). Once you've replicated it you'll need to go through each of those files and replace any references to "information" with "mymodule".
After that, if you've done it properly, you should be able to navigate to Admin > Extensions > Modules and see your module in there. Then install it, use the "Add module" button to position the module on all the relevant layouts, hit save and hey presto you have a working module on the front-end.
To modify the front-end output, just edit catalog/view/theme/default/module/mymodule.php
If you want to insert your HTML somewhere other than the 4 available positions OpenCart gives you, position your module in the content-bottom position and use JavaScript/jQuery to inject some HTML where you want.
If this is for your own personal website then as Pawel S suggested it would be easiest to simply modify the relevant view files (ie. catalog/view/theme/[themename]/template/product/product.tpl), however if you're making a module which you plan to distribute then this should be a last resort.
Hope that helps!
I realize this is probably long dead by now, but if you're creating a module that needs to modify existing controllers, languages, models or views the correct tool to use is vQMod.
vQMod allows you to modify existing code on the fly using XML.
https://code.google.com/p/vqmod/

Editor or IDE supporting django templates and HTML/CSS validation?

Is there a IDE that supports editing django templates and that is able to validate HTML and CSS?
Requirements:
be able to detect and highlight errors in CSS, example: forgot to close "}", or invalid css attribute
be able to make it learn new css attributes (like css3 ones or browser specific ones) - we don't want to see them invalidating the css
validate partial-HTML, like the one from inside django templates.
has to run on Windows
Python support (optional / bonus)
I know that there are many cool Python IDEs but I found none that can be used to edit and validate HTML/CSS django-templates.
You can use geany (http://geany.org/) that support html/css and allows you to define your own snippets (http://configer.net/config/show/geany-html-and-django-snippets/) for django template language.
PyCharm from IntelliJ.
PyDev for Eclipse/Aptana