On Thu, Jul 9, 2009 at 3:29 PM, Wiiboy<[email protected]> wrote:
>
> Hi,
> On the homepage of my website, I have three columns of articles from
> users. I can't quite figure out how to make those three columns
> without violating DRY. Now, I have a dictionary of lists, with each
> list being the list of articles for one column. I then loop through
> the lists. Example:
>
> <div id="column_left">
> {% for article in articles.left %}
> {{article}}
> {% endfor %}
> </div>
>
> <div id="column_right">
> {% for article in articles.right %}
> {{article}}
> {% endfor %}
> </div>
>
> <div id="article_center">
> {% for article in articles.center %}
> {{article}}
> {% endfor %}
> </div>
write a column template:
-------
{%or article in col_articles %}
{{article}}
{% endfor %}
-------
and call it three times, with a different col_articles:
-------
<div id="column_left">
{% with articles.left as col_articles %}
{% include "column.html" %}
{% endwith %}
</div>
<div id="column_right">
{% with articles.right as col_articles %}
{% include "column.html" %}
{% endwith %}
</div>
<div id="column_center">
{% with articles.center as col_articles %}
{% include "column.html" %}
{% endwith %}
</div>
---------
--
Javier
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---