Commits

Anonymous committed 3c0e7e0

changes in templates

Comments (0)

Files changed (4)

cmsplugin_news/templates/cmsplugin_news/base.html

+{% extends "base.html" %}
+
+{% load cms_tags %}
+{% load i18n %}
+
+{% block main %}
+    {% block newscontent %}{% endblock %}
+{% endblock %}
+
+{% block leftblock %}
+{% endblock %}
+
+{% block title %}
+    {% page_attribute title %}
+{% endblock %}

cmsplugin_news/templates/cmsplugin_news/news_archive.html

-<h1>Latest news</h1>
+{% extends "cmsplugin_news/base.html" %}
+{% load i18n %}
+{% load cms_tags %}
+{% load cms_news_tags %}
+
+{% block newscontent %}
 
 {% for object in latest %}
-	<p><strong>{{ object.title }}</strong><br/><a href="{{ object.get_absolute_url }}">Read more</a></p>
-{% endfor %}
+    <div class="news">
+        <h3><a href="{{ object.get_absolute_url }}">{{ object.title }}</a></h3>
+        {% if object.image %}<div class="news-preview"><img src="{{object.image}}" alt=""></div>{% endif %}
+        <div class="news-text">
+        {{ object.content|textcut}}
+        </div>
+    </div>
+{% endfor %}
+
+{% endblock %}

cmsplugin_news/templates/cmsplugin_news/news_detail.html

-<h1>{{ object.title }}</h1>
+{% extends "cmsplugin_news/base.html" %}
+{% load i18n %}
+{% load cms_tags %}
 
-<p><span class="date">{{ object.pub_date }}</span><br/>
-	{{ object.content|safe }}
-</p>
+{% block newscontent %}
+    <h1>{{ object.title }}<span class="date">{{ object.pub_date|date:"d.m.Y" }}</span></h1>
+    {{ object.content|safe }}
 
+{% endblock %}

cmsplugin_news/templatetags/cms_news_tags.py

 from django import template
 from django.utils.safestring import mark_safe
+from django.utils.text import truncate_html_words
 from cmsplugin_news.models import News
 from django.conf import settings
 
         self.count = count
 
     def render(self, context):
-    	news = News.published.all()[:self.count]
+        news = News.published.all()[:self.count]
         context[self.varname] = news
         return ''
 
 
 @register.filter
 def textcut(text, autoescape=None):
-    try:
-        beforesep, aftersep, sep = text.partition('<!-- pagebreak -->')
-    except:
-        beforesep = text
-    return mark_safe(beforesep)
+    short_text = truncate_html_words(text, 50)
+    return mark_safe(short_text)