in "teaser.html" the first line is {% load page_teaser_tag %} and the
second line using the only tag in it
will check the blog tags for further learning
thx
Roland
On Wednesday, April 8, 2015 at 4:31:57 PM UTC-4, Josh Cartmell wrote:
>
> Hi Roland, as far as I can see you aren't using the templatetag correctly
> and actually never call it.
>
> {% load %} is called with the name of a templatetag file to make
> available all the tags in it. From there you would need to actually use
> the tags.
>
> Also, you either need to call the tag within teaser.html or have the tag
> render teaser.html. What it looks like you are trying to do would do both
> and result in an endless recursion.
>
> My recommendation would be to make it an as_tag instead of a simple tag.
> Here's an example of an as_tag from Mezzanine,
> https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/blog/templatetags/blog_tags.py#L54
>
> and the way it is used,
> https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/blog/templates/blog/includes/filter_panel.html#L4
> .
>
> Then include teaser.html and within it call the as_tag and render the page
> it returns.
>
> Also, maybe take a look back over the templatetag docs,
> https://docs.djangoproject.com/en/1.8/howto/custom-template-tags/#simple-tags
>
> Good luck!
>
> On Wed, Apr 8, 2015 at 3:48 PM, roland balint <[email protected]
> <javascript:>> wrote:
>
>> trying but, page_teaser_tag.py doesn't get triggered at all ( do have
>> __init__.py in templatetags folder )
>> in index.html
>> {% include "teaser.html" %}
>> in teaser.html
>> {% load page_teaser_tag %}
>> <p>{{ single_page.description|safe|truncatechars:50 }}</p>
>> in page_teaser_tag.py
>> from __future__ import unicode_literals
>> from django.shortcuts import get_object_or_404, render_to_response
>> from mezzanine.pages.models import Page
>> from mezzanine.template import Library
>>
>> register = Library()
>>
>> @register.simple_tag(page_teaser)
>> def page_teaser(request, slug):
>> """
>> return the requested page
>> later would like to be able to send which page to be returned
>> """
>> slug = 'about-us'
>> single_page = get_object_or_404(Page, slug=slug)
>> return render_to_response('teaser.html', {'single_page':
>> single_page,})
>>
>>
>> On Tuesday, April 7, 2015 at 2:16:15 PM UTC-4, Josh Cartmell wrote:
>>>
>>> Hi Roland, first use a page process, template tag or some other method
>>> to pull the page you want to show content from onto the home page.
>>>
>>> Then use either https://docs.djangoproject.com/en/1.8/ref/templates/
>>> builtins/#truncatechars-html or truncatewords_html to cut the text down
>>> to the size you want.
>>>
>>> Good luck!
>>>
>>> On Tue, Apr 7, 2015 at 2:00 PM, roland balint <[email protected]> wrote:
>>>
>>>> not sure if this has already been asked or done...
>>>> how can we do a page teaser?
>>>> was thinking about the first 100 character from a rich text page to be
>>>> displayed on the index page
>>>> thank you,
>>>> roland
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Mezzanine Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Mezzanine Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.