Let me explain a little bit what I'm working on :
I am an intern and I have to create a friendly website back-office for people who are not really used to computer.
Thus, the back office management has to be as simple as possible ! I already put a lot of drag & drop in my plugins, the front-end is cool etc.
But a problem subsist :
the templates and placeholders.
I managed to create a demonstration template page with multiple placeholder, some in full width and some in 6 columns, 4 columns etc.
So I have something like that :
<div fullwidth>
{% placeholder "title1" %}
</div>
<div 6 columns>
{% placeholder "text1" %}
</div>
<div 6 columns>
{% placeholder "Picture1" %}
</div>
<div fullwidth>
{% placeholder "text2" %}
</div>
Each place holder has default plugin, in order to helps users.
Ok it works great.
But what happen now if we want, in the website back-office, move the placeholder "text2" before the 2 six columns ?
It seems to be impossible to manage it dynamically.
If you have used wordpress, you must have experienced how easy is it to manipulate content, if you want to move a Title to an other location juste drag and drop it etc.
Then I was thinking about the multiple column, by default you would have a multiple column with one 100% width column. Up to you to reduce it.
But the problem is that it is complicate to integrate and modify.
And it is absolutely not friendly-user !
Well, in case I am not very clear, I need to manage placehoder positions dynamically or have something to manage multi columns in an easy way for the user !
I am totally lost and without idea about it.
Have you already experienced it ? What kind of option did you choose ?
It would be really great if you could share some point of view with me :)
By the way,
thank you in advance for reading my post.
EDIT :
Have you seen this : http://www.mir.de/django-cms-demo ? This is perfectly what I want to have. But I don't know how they are doing it... And it is in German language...
Have you tried djangocms-cascade? I allows one to create placeholders on the fly and it should allow to order thus created placeholders.
According to its github page:
DjangoCMS-Cascade allows web editors to layout their pages, without having to edit Django templates. In most cases, one template with one single placeholder is enough. The editor then can subdivide that placeholder into rows and columns, and add additional elements such as buttons, rulers, or even the Bootstrap Carousel.
I would like to recommend:
https://github.com/divio/djangocms-column
or
https://github.com/divio/djangocms-grid
Its a lot simpler compared to djangocms-cascade.
Related
I am learning Django and i learn on making small project for lEARNING PURPOSE.
I learned how work with input and use as variable. Now i want to use search box with the same principle.
Please see the link of input based :
https://stackoverflow.com/questions/58813945/changing-form-to-search-box
index.html is the input after inserting info and clicking ok it directs to index2.html which shows the results
What I need to change besides POST to GET to make it work as it works with input function? do i need to change form, models?
My concern also i want to inset search bar in the navigation in index2.html where user can make search from the result page. This is my index2.html page. I tried to put {{form.as_p }} inside the form function but it does not work. I want after putting infro in search box and clicking search glyphicon (which does not work) will stay on the same page index2.html
I searched the internet and read stackoverflow other examples, but they use complicated version, i need a simple one :
1. i want to have search box on index.html page so it does not show me the name in front of input box and
2. i want search box in the index2.html page keep implementing the same function as index.html so a user do not have to go the initial page to search new data.
Any help or tips would be highly appreciated.
Since you're using bootstrap4 I would recommend to use its template tags and form field customization options.
Example:
{% bootstrap_field form.login show_label=False addon_before='<span class="fa fa-user"></span>' %}
Not: this example uses Font Aweseome for icons.
Also you're not using the real power of Django Bootstrap4, see Quickstart. You can always override the version of Booststrap or the CDN used in your settings.py if needed: Settings.
Sorry this is a bit of a noob question.
I have a student model.
I have multiple places where the student's profile is shown. each place is a different View and template file.
Currently I'm copying and pasting the html between template views. But this means that when I make a change to the layout of the student profile I need to update it in multiple locations.
Having the exact same html code in multiple places seems to be against DRY.
What is the best way to do this in django? or are the HTML blocks considered WET stuff?
just add an include tag where you'll need it like so -
<div>
stuff
{% include 'sometemplate.html' %}
more stuff
</div>
i am very confused right now. I came from Wordpress,and laravel frameworks, and now i am assigned to develop Joomla! project.I thought i can easily manage to create custom template in joomla. I have been reading a lot of articles and documentation. I've manage to create a template and display modules.
But now, i need to start digging the right way to display the content and manage it in Joomla! back-end.
Here's my problem. I have home page (Long page) and inner pages (Short page). Here's the structure of my homepage
<html>
... header links and other necessary tags
<body>
<section class="homepageonlysection1">
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
<div>
video here (i made this as 1 modules in Custom HTML)
</div>
</section >
<section class="homepageonlysection2">
<div>
form here (i made this as 1 modules in Custom HTML)
</div>
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
</section>
<section class="homepageonlysection3">
<div>
image and text here! (i made this as 1 modules in Custom HTML)
</div>
<div>
video here (i made this as 1 modules in Custom HTML)
</div>
</section>
</body>
</html>
and this is my inner pages
<html>
... header links and other necessary tags
<body>
<section class="innerpagessectiononly1">
<div>
Article Content (i will do as jdoc:inlucde type="component")
</div>
</section>
<section class="innerpagessectiononly2">
<div>
sidebar Content (i will do this as 1 modules in Custom HTML)
</div>
</section>
</body>
</html>
Those template are really different.
Problem 1 : How can i make my inner pages if my homepage structure is very different? Or
Problem 2 :How can i make display my section (homepageonlysection) in home page only and display (innerpagessectiononly) in inner pages only?
Problem 3 : Is there a Advance Custom Field (ACF for wordpress) as joomla extension ?
Please advice. Any help would be appreciated.
One thing I recommend is really digging into the core templates (both front and backend) to understand how things work. In particular Isis the backend template illustrates a number of complex options.
Now, overall I think you probably do not want to do the homepage the way you are doing it, since it will be very inflexible and hard to change. On the other hand it's possible that you want it inflexible and hard to change. In reality you may not need to have separate layouts at all or the differences may be minimal and may not require any special code at all.
So, first, this document explains how to determine if you are on the home page. So you can clearly pretty easily test for that and then enclose your two separate designs in the true and false conditions. This is basically what you see in Isis. In your case you can place one or more module position inside the condition. In fact you could make it so this layout does not even load a component. Then you can just make an empty article and make the home page a single article link to that empty article. (I would put that article into a separate landing page category)
A second option if you really want to have a totally different design on the home page is to make a totally separate template for the home page. If say you called this "my home template" and your other template "my everywhere else template" what you could do is make "my everywhere else template" the default and then on the default (homepage) menu item assign the "my home template" template. In this special template you can even use the module jdoc:include (instead of modules) to call specific modules in highly customized ways. I would suggest you go read the docs on that. You can even set the options and the chrome right in the template.
However, I think you are missing a key feature of Joomla. In your question you have not said what kind of menu link you are planning to use for your home page. The third option is that for the homepage you use the same template but a specific alternate layout that you use for this page. For your case what you would most likely want to do, assuming that you are not using the featured articles layout type anywhere else (i.e. that no articles are marked featured), is to make your homepage using an articles > featured menu link. Then you can assign all the modules you made to the home page via the menu modules tab. Depending on how your module positions are in the template it could just be that they will float up.
Your design is not a particularly unusual or complex however. Many Joomla homepages consist of multiple structured sections of text and media. These are made with menu types such as "featured" and "category blog." The advantage of using these menu types is that then you are storing your content in articles and these are much easier to manage. ALso you don't have to give someone access to the module manager in order to allow them to edit these snippets of content. So the fourth and possibly best approach is to use one of these standard content layouts. For example if you were to make a category called "home page content" and then put the content for each of the modules in a separate article and (assuming you want a consistent structure) put the image for each of them into the structured intro text image field, you can then make a "category blog" menu link to the "home page content" category as you default (home page) menu link. Then what you can do is make one or more layout override for those individual items that gives the exact layout you want. Assuming that they are all the same, you can select that as a alternate layout in your menu link. Actually even if they are not all the same you can just do a more complex layout instead of looping through the list and doing the same thing for each article, do each one separately.
A fifth approach is to use an alternative layout instead of an alternate layout. The difference there is that you would give the layout a new name (in either the category or featured view) and then you will have the additional flexibility of being able to create options in the menu link that are different than those for the normal category/featured views. It's up to you to decide what you might want to add there.
There are other options as well, because Joomla has a very strong template community and they like to have a lot of flexibility. But that will get you started.
I’m planning to use the Django templating system in a slightly uncommon way. I need an app that will let me easily create simple “fill in the gap”-style forms and I decided to use Django templates with custom tags to design the forms.
Here is a sketch of what I mean:
<p>
This is the <i>form</i>. Two plus two is {% gap four 4 vier %}.<br>
The best programming language is {% case_gap Python Haskell %}.
</p>
{% if all_correct %}
You are smart.
{% else %}
<input type="submit">
{% endif %}
The idea is that the *gap tags render a text input control, look into the context to see if the answer for them was sent, and if the answer is correct, mark the text inputs green.
The question is how to implement the all_correct logic. The simple solution is to add this variable to the context and then make each *gap tag update it based on its correct answer, and, I believe, this should work with my example. But what if I want to move the {% if all_correct %} code to the top of the template, where none of the gaps were rendered, and thus none of them have validated their answers yet?
Looks like I need some way to iterate over all the *gap tags before starting to render the template and [ask them to] validate the answers, but I don’t know the internals of the templating system well enough to implement this. Or there might be a completely different and better way.
I believe I figured how to do this after reading Chapter 9 of The Django Book.
Creating of a custom template tag involves defining of two things: how to compile the tag and how to render it. The compile-function should parse the tag data and return a Node—basically a thing that has a .render(self, context) method and some other data derived from the tag text.
The solution is to create FormNode—a subclass of Node that will also have a .validate(self, context) method. Then our custom tag will be compiled to a subclass of FormNode that implements validation logic.
The next thing to do is to create FormTemplate—a subclass of Template with a super-power: before starting to render individual nodes it will validate all the nodes by iterating over them and calling validate(context) on all the subclasses of FormNode and it will set the all_valid variable in the context.
Here is my proof-of-concept implementation: https://github.com/kirelagin/django-template-forms. I believe it works pretty well.
I used the ability to instantiate a custom template engine, which was added in Django 1.8. Overall, I had to dig a little deeper than one might expect and I always had this feeling that splitting of the templating API and the django engine (which is now just one of the available backends) wasn’t complete yet. I hope that Django 2.0 will bring us new cool stuff and all the hacks I had to add will vanish.
I'm having a hard time coming up with a solution for this problem.
I'm building a WYSIWYG designer, for micro sites. The templates for these microsites will be supplied by an intermediate user, and the end-user will manipulate these templates. So, there are really two groups of users of the app: template-buiders, and end-users. Think MailChimp.
This means my Ember app will start off with a template from a template-builder, say
<h1>An awesome product</h1>
<h2 contenteditable="true">Subtitle away</h2>
<p>{{#if optionA}} One thing {{else}} Another thing {{/if}}<p>
and the end user, having chosen this template, will then be able to customize it. There are a few requirements:
There will be static, uneditable portions of the page (h1 above)
There will be static, editable portions of the page (h2 above)
There will be options that affect the layout, style, etc. (p above)
So far, my attempts have lead me to build a handlebars helper that takes a string and a context, and returns a rendered template. This is because the above template will actually be coming over from a database, as a string - remember, it's user-generated.
That means, in my application's template, it would look like
<div class="preview">
{{preview-userTemplate template context}}}
</div>
where
template: '<h1>An awesome product</h1><h2 contenteditable="true">Subtitle away</h2><p>{{#if optionA}} One thing {{else}} Another thing {{/if}}<p>',
context: {optionA: true}
Now, this actually works, in the sense that it will update if context is updated, so I can add controls along the sides for the end-user to manipulate those options. So I have those (more of less) under control.
It's the WYSIWYG content editing that is giving me trouble. In the above template (from my template-builder users), I want them to be able to add contenteditable="true" to places in their templates where the end-users can change the content.
Now, these changes need to be saved. Ideally, I would be able to retrieve the instance view's template back from the DOM, after the inline edits have been made. Is this possible? The original {{data}} placeholder would need to be preserved.
Alternatively, I could make a view/component, so the template-builder would do something like this:
<h1>An awesome product</h1>
{{#editable}}
<h2>Subtitle away</h2>
{{/editable}}
<p>{{#if optionA}} One thing {{else}} Another thing {{/if}}<p>
but this seems like it would require a good deal of finagling to get the edits to stick - I'm not even sure right now how I'd go about it.
What do you guys think? Is there an easier solution that I'm overlooking? Thanks for any pointers!