Promotions carousel on homepage

126 views
Skip to first unread message

Bastien Roques

unread,
Jan 7, 2017, 5:10:02 AM1/7/17
to django-oscar
Hi,

What is the good practice for including a carousel on the homepage. For now, what I've done is simply adding a multiimage promotion block to '/' which is working only if I remove the condition block `if promotions` thatt wrap the call to the promotions_page templatetag in the template 'layout.html'.

in layout.html

{# {% if promotions %}#}
<div id="promotions">
{% for promotion in promotions_page %}
{% render_promotion promotion %}
{% endfor %}
</div>
{# {% endif %}#}

So my question is what is this 'promotions' var in layout.html template for? Does it mean that I have to override HomeView and add to its context a 'promotions' var set to True ?

I really would appreciate any help !  
Message has been deleted

Bastien Roques

unread,
Jan 9, 2017, 5:21:58 AM1/9/17
to django-oscar
As far as I understand, the promotions/context_processors.py is aimed to add promotion blocks accordingly to their position. So we have access to 'promotions_page' or 'promotions_' + 'left' or 'right' depending the case. I don't see that the context_processors is intended to work with a 'promotions' var.


In this case, I don't understand why we test something else than promotions_page which is the var parsed in the `for` loop.

So I still wonder why is this 'promotions' var for? Do I misunderstand something? Wouldn't it be more logical to have 'promotions_page' instead ?

cmmwa...@gmail.com

unread,
Jan 9, 2017, 8:00:10 PM1/9/17
to django-oscar
Do you mind clearing your question since its a little bit unclear. Are you asking about the promotions var on the

{% render_promotion promotion %}


Bastien Roques

unread,
Jan 10, 2017, 3:29:18 AM1/10/17
to django-oscar
Sorry for the opacity of my question. I talk about the if statement in `layout.html` :

{% if promotions %}

I don't see any context with a such 'promotions' var. Instead you've got a 'promotions_page' in the context, brought up by the promotions context processor. So, to me, it's clear that the loop in the template layout.html should be:

{% if promotions_page %}

<div id="promotions">
{% for promotion in promotions_page %}
{% render_promotion promotion %}
{% endfor %}
</div>
{% endif %}

But maybe I misunderstand what's for?

cmmwa...@gmail.com

unread,
Jan 10, 2017, 3:10:42 PM1/10/17
to django-oscar
What version of Oscar are you using? Am looking through the source and all I can see is:

   
layout.html

{% block subnavigation %}{% endblock %}
               
<div class="content">
                   
{% block subheader %}{% endblock subheader %}

                   
{# Render promotions #}

                   
<div id="promotions">
                       
{% for promotion in promotions_page %}
                           
{% render_promotion promotion %}
                       
{% endfor %}
                   
<
/div>

                    {# Div exists for AJAX updates to entire content section #}
                    <div id="content_inner">{% block content %}{% endblock %}</
div>
</div>

I don't see the {% if promotions %}
Message has been deleted

Bastien Roques

unread,
Jan 11, 2017, 5:26:02 AM1/11/17
to django-oscar
But I've seen effectively that this useless if statement has been removed in the latest version.

Is there a way to check if from the 1.3 version I've installed there is big changes worthing to update the project?

Bastien Roques

unread,
Jan 11, 2017, 10:42:14 AM1/11/17
to django-oscar
This is stupid, I have the last version. Anyway, reading the code makes me understand better the way it works. Thanks
Reply all
Reply to author
Forward
0 new messages