best practice for extending dynamic templates? - django-templates

I need to render nested templates and as obvious these templates have many to many relation (eg. forum calls news, menus, videos etc.. and vice versa).
Im new to DJango and the only solution I can think abt is repetitive calls between them.
Any idea?
Thanks

this may prove to be helpful. It has got some documentation on extending django templates. Also see here for some info on the template inheritance mechanism. If you want to extend the template engine, then see here.

Related

django allauth with jinja2 templates

I would like to know if it is possible to use the django-allauth app with jinja2 templates instead of DTL templates.
There does not appear to be any clear information about this, or usable examples available. I am unsure if this is because its easy and therefore doesn't warrant its own explanation, or because its impossible.
I am aware of this feature request, but it is 3 years old.
Yes, it is. You'll need to use crispy forms in jinja templates though.

Is it possible to use Aurelia in a non-spa application?

Recently I've been playing around with different frameworks and libraries, looking for something that really suits my needs.
You see, my job mainly involves creating asp.net mvc applications and for most of them using Razor and a little bit of jQuery is enough. But in certain cases and only for a few pages,which are rarely more than one or two per app, I really need something extra that helps me avoid getting entangled in a bunch of jQuery code.
As I mentioned, I tried a couple of alternatives and from them, the one I liked the most is Aurelia, because of its simplicity and the fact that it embraces standards, BUT the more I dive into the framework, the more I think that it might not be what I'm looking for,as it seems more suitable for full spa applications and what I need is:
Something that helps me reduce the amount of DOM manipulation
A efficient templating engine
I know that Aurelia provides that and much more, but I don't want/need a SPA, I need those functionalities ONLY in some specific pages and not the whole application.
Can Aurelia help me achieve this? If so, how?
Sure, Aurelia can help you achieve that. You just won't use certain features like routing in on the pages you create with Aurelia.
That being said, it isn't a drop in replacement for jQuery, but none of the "modern" JS frameworks really are. And you're going to end up spending time learning whichever one you end up choosing.
Check out the aurelia.enhance functionality, it might be just what you're looking for!
I have used Aurelia in a non-SPA context, and it worked out well. I think this is exactly what you describe. For example:
http://legumeinfo.org/chado_phylotree/phytozome_10_2.59028020
https://github.com/legumeinfo/tripal_phylotree/tree/lis_master/theme/js/aurelia
I'm using aurelia for dynamic elements on some sites. Like comments for example. Page loads fast w/o comments.Then Aurelia kicks in and loads the comments below. Also with some signalR magic the discussion is updated in real time. It is awesome and insanely easy.

Dynamically adding data to divs with SQL?

A little background first, recently began coding and I decided to take the "learn as you go" approach as this is solely a project. I have a pretty good handle of HTML and CSS, I have an understanding of Jquery, and haven't even begun to look at other languages.
So basically I'm making a suedo-e-commerce site, and I'm trying to create a page layout comprising of several divs stacked together (think standard catalog page) Creating the modules and every static with HTML and CSS, but I want to add the content, comprising of a banner and some text blocks, dynamically from a database. Now, I'm pretty sure that I will have to use SQL and reference each entry with the HTML, but I have no idea how to do that or where to even start. So I'm asking if someone could point me in the right direction with some reading material, or some examples would be awesome.
You need to use one of databases (MySQL, MSSQL etc.) to save data. In order to show data from database you need to use one of background/server side programming languages. For start I would suggest that you try with php.
W3schools is good starting point for you.
This is very simplified and I hope not condescending. Consider separating how you collect your data and you present your data (the 'view layer'). SQL will help you pull / organize your data, and you could just string functions to add formatting (e.g. div's) to it, but you are better off investigating templating HTML. What happens when you want to put this data into a ul list or something? You have to re-write your perfectly good SQL. Again, very broadly, pull data (with SQL, PHP, combination), ( or get it from a URL with javascript), into a data structure, then within a loop in your template, add the dives for each element.
Good reading really depends on which platform you'll be developing this in. There are a bazillion alternatives, including many in Javascript, PHP, Ruby, Python, Go, ASP. Since you mention SQL, you must have some data somewhere (rather than a data service) so you'll need a server-side language, and since you are a beginner, you may want to look into PHP which I think is approachable. Within that there are several PHP frameworks for data, and several for templating, and several with both. Many of the full frameworks (in any language) are geared for experienced web devs. That said, I like the twig templating language for PHP
This, I think, is a good place to start http://www.phptherightway.com along with the super popular but basic W3schools. The link above I think organizes the concept a little better.
You can install the stuff you need on your laptop for that standard (and old school) 'LAMP stack', or use one of the many hosting companies, nearly all of which provide everything you need. good luck learning!

Best practice Sitecore Placeholder in rendering, share content

Im sure this has been asked before, but as far as I can see no one seems to mention the best practice for this case.
I have a body-placeholder that basically wraps everything of my page.. with in this placeholder the user is allowed to add "Section Renderings" each section rendering contains two additional Placeholders...
When adding two or more Section rendering however.. they seem to share the content that gets added in their two placeholders... and I guess this is since the placeholders are all sharing the same name..
Whats the best practice for this?.. I have read about people creating extensions of Html.Sitecore() and adding a what they refer to as a "Dynamic Placeholder"..
But well my question remains :).. whats the best practice for solving this issue?
#jammykam is correct. Sitecore does not support dynamic placeholders out of the box and you will need to implement an extension built by a third-party, or build your own version that meets your needs.
Personally, having had to dig into this a little in the past, I do not recommend starting from scratch and trying to figure it out. The available resources from other folks who have done the hard work will get you much further.

Help with design problem (extending a generic inteface)

I am part of a studentproject and we are to develop a product for a company using Java EE. As "lead architect" in the project I am responsible for composing a good design which should be flexible for further extensions.
Background info: We are to develop a website with a drag and drop GUI with possibilites to connect data sources with data manipulations to perform on that specific data. The GUI should be generic and possible to integrate with upcoming products. This means that we cannot code to an implementation in the presentation layer. Instead we will use an interface to define what kind of data manipulations that are possible for all kinds of products. However, each product might also sport product specific data manipulations (thus extending the interface with more methods).
The problem I have with the scenario above is that I dont see how we could pass on these "product specific data manipulations" to the GUI and say that, in addition to the generic interface, we also possess these data manipulation actions...
Now I had a discussion with some of the more experienced programmers from the company and they told me that there is a common solution to this problem - more specifically known as the "Observer pattern". They draw something like [1] on the whiteboard and explained that it would be possible to "register" to a third party (getApplicationContext) that in turn could convey our product specific interface. This is a common problem to get rid of those nasty circular dependencies, they explained.
I have now had a look on the observer pattern and how it works and I still dont really get how I am supposed to solve the design problem. Could someone possibly try to explain how it would turn out in my specific scenario? I have no real problem understanding how it works with "subjects" and "observers".
Here is an UML diagram of the design where we are using a reference of the specific product. This is what is undesirable and something we would like to get around.
(maybe I got this all wrong...)
I am sorry but I cant change the picture to the correct one as I am a new user... Here is a link to an updated UML diagram:
It seems what you are looking for is the Model View Controller design pattern. The Observer pattern is just a part of this design pattern. There is a short description for doing this with Java Servlets and JavaServer Pages from Java EE on the wikipedia article.