I'm trying to have a list of images in a doc all hidden in css with
next and prev links that unhide and hide to give the appearence of
scrolling through.

I'm struggling with the Django template system. I know this is putting
logic into templates rather than views but it seems odd to move simple
logic like this further away from the place it's controlling. If my
brain is still too tainted by PHP then please correct me.

here's what I've got:

    {% for item in site_details.Photos.all %}
        <div class="imgbox" id="img{{ forloop.counter }}">
        <h3>{{item}}</h3>
        <img src="media/photos/thumbs/{{item}}"><br>
        {% if not forloop.first %}
            <a href="javascript:void(0);" onclick="showPhoto('img{{
forloop.counter - 1 }}' );">prev</a>&nbsp;
        {% endif  %}
        {% if not forloop.last %}
            <a href="javascript:void(0);" onclick="showPhoto('img{{
forloop.counter + 1}}' );">next</a>
        {% endif  %}
        </div>
    {% endfor %}

It constructs a div for each image with an ID set to img1, img2 etc.
and then adds an onclick handler that calls a js function with the
appropriate values.

The trouble is how to get the value of forloop.counter minus one and
plus one. My pseudo-code solution obviously doesn't work and I can't
suss out the correct syntax using filters. What's the best way to do
this (apart from the obvious 'you shouldn't answer)

As I type this it dawns on me that all this logic could be moved into
javascript with some nextSibling and prevSibling code but I'd still
like to


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to