show_sub_menu and Placeholder

Showing 1-3 of 3 messages
show_sub_menu and Placeholder optimum...@laposte.net 11/21/11 2:00 AM
Hi,
in order to list subpage of a page, im using "        {% show_sub_menu 1
"menu/list.html" %}"

this subpage can be from differents templates, so placeholder are not
the same  (for instance some has a placeholder named "image" and some
doesnt)
So when I make subpage list, I would like to display placeholder image
if it exists, and just not display if it doesnt.

But as django cant find placeholder "image" in some template, I have
this error : "Caught DoesNotExist while rendering: Placeholder
matching query does not exist."

Is there a way to avoid this ?

thanks

Re: show_sub_menu and Placeholder Martin 11/21/11 7:46 PM
The question is not precise enough.
Do you mean that in your list.html you somehow query the placeholders of that child in order to render an image?
If so, please tell us, how you query and render that image.

Anyhow I guess in this case it would make sense to create a new template filter that takes the submenu-item node as an argument and returns a URL to the image.
In your template you could do something like this:

{% if child|get_image_url %}
  <img src="{{ child|get_image_url }}" />
{% endif %}

Just wild guesses here :)

Cheers,
Martin


--
You received this message because you are subscribed to the Google Groups "django-cms" group.
To post to this group, send email to djang...@googlegroups.com.
To unsubscribe from this group, send email to django-cms+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-cms?hl=en.


Re: show_sub_menu and Placeholder optimum...@laposte.net 11/22/11 1:54 AM
Hi

thanks for answer.

First I was just doing {% show_placeholdervar "image" child.id %} and
as I had this problem, i made a templatetag who put placeholder in a
variable. I used example of image in my post, but placeholder can be
just a text and still the same problem


                {% show_placeholdervar "mytext" child.id as vartext %}
                {% if vartext %}
                <div class="ai">
                        {{ vartext }}
                </div>
                {% endif %}
                {% endshow_placeholdervar %}

thanks again for your help

On 22 nov, 04:46, Martin <martin.brochh...@googlemail.com> wrote:
> The question is not precise enough.
> Do you mean that in your list.html you somehow query the placeholders of
> that child in order to render an image?
> If so, please tell us, how you query and render that image.
>
> Anyhow I guess in this case it would make sense to create a new template
> filter that takes the submenu-item node as an argument and returns a URL to
> the image.
> In your template you could do something like this:
>
> {% if child|get_image_url %}
>   <img src="{{ child|get_image_url }}" />
> {% endif %}
>
> Just wild guesses here :)
>
> Cheers,
> Martin
>
> On Mon, Nov 21, 2011 at 6:00 PM, optimum.dulo...@laposte.net <

>
>
>
>
>
>
>
> optimum.dulo...@laposte.net> wrote:
> > Hi,
> > in order to list subpage of a page, im using "  {% show_sub_menu 1
> > "menu/list.html" %}"
>
> > this subpage can be from differents templates, so placeholder are not
> > the same  (for instance some has a placeholder named "image" and some
> > doesnt)
> > So when I make subpage list, I would like to display placeholder image
> > if it exists, and just not display if it doesnt.
>
> > But as django cant find placeholder "image" in some template, I have
> > this error : "Caught DoesNotExist while rendering: Placeholder
> > matching query does not exist."
>
> > Is there a way to avoid this ?
>
> > thanks
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "django-cms" group.
> > To post to this group, send email to djang...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-cms+...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-cms?hl=en.