Creating custom django shortcode - django

how can i create my custom shortcode?
I did install 'django-shortcodes' application added it inside project settings loaded it inside my template... what next?
I need to create my personal short code.

I'm assuming you are talking about https://github.com/martey/django-shortcodes
You will need to fork it and add new parsers in the shortcode directory.
See here :
https://github.com/martey/django-shortcodes/tree/master/shortcodes/parsers

Related

Overwrite a Django Material Admin template and keep it inside Project Folder

I'm working with Django Material Admin framework. I want to overwrite a template(example: clearable_file_input.html) and place the overwritten template in the project folder to get the updated functionality of the template while running the project.
Where do I need to place that updated template inside the project?
What are all the changes (if there is any like updating settings.py file) that I need to do for automatically fetching the updated template but not the original template?
Example Scenario: I want to update the functionality of opening a link (of TabularInline Model) when it's clicked. I want to open the link in another tab when it's clicked. So, I got to know that I need to update the clearable_file_input.html and I successfully updated that. Now I need to figure out where do I need to place this file inside my project to get the updated functionality.
I don't want to update the original template present in the path: "./local/lib/python3.7/site-packages/material/admin/templates/admin/widgets/clearable_file_input.html"
I want to place the updated template in project so that while running the project, the updated template is taken rather than the original template present in the previously specified path.
What do I need to do for this functionality to work?
You need to override the template as answered here but in my case, I had to do three more additional step which was to use TemplateSettings renderer instead of the default one.
Step1: You need to add the following line in your django's settings.py
FORM_RENDERER = 'django.forms.renderers.TemplatesSetting'
Step2: add the following to your DIRS list in TEMPLATES config
django.__path__[0] + '/forms/templates'
Step3: add 'django.forms' in your installed apps.
That'll do the trick!

How can I personalize the template of the django-oscar?

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.

do we have to use static-content:deploy for every small change in our custom jascript in magento

i am creating one custom javascript file in magento admin side.i need to use static-content:deploy every time to reflect the change in javascript .so it's taking very long time to see the output.so what is the standard way to use the custom javascript snippet
Suggestion is to have that JS as online JS rather then in .JS file.

how can I use IntelliJ live edit with django templates?

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.

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/