* AH-SID I want to make my xtblog template, but in some part (in bold text) I don't know what should I do.

Here my code:

{% block entries_list %}
{% for entry in data.entries %}
<div class="item">
<div class="box1">
<h2 class="title"> <a href="{{ entry.url without any query }}">{{ entry.title }}</a> </h2>
</div>
<div class="description">{{ entry.content short description }}</div>
<div class="box2">
{% if there are have an image %}
{{ first.image }}
{% else %}
<img src="/default.png" />
{% endif %}

</div>
<div class="box3">
<span>{{ entry.comments_count }} Comments</span>
</div>
</div>
{% endfor %}
{% endblock %}
2014-06-16 09:02 · (0)
* Graham * AH-SID Part one is fairly easy
<div class="box1">
{% set url_no_query=entry.url|split('?') %}
<h2 class="title"><a href="{{ url_no_query[0] }}">{{ entry.title }}</a></h2>
</div>

Copy code

twig split filter
http://twig.sensiolabs.org/doc/filters/split.html

part 2 is trickier as that requires splitting up the description so soon (maybe tomorrow)
2014-06-16 12:35 (edited 2014-06-16 12:57 by Graham ) · (1)
* AH-SID * Graham Ok, I'll wait for that :)
2014-06-16 19:12 · (0)
* Graham * AH-SID This is really a bit of a hack job but it does what you want
{% set img_http=entry.content  |split('"') %}
{% if img_http[3] starts with 'http' or img_http[3] starts with '/' %}
{% set short_desc=entry.content |split('</a>') %}
<div class="description">{{short_desc[1]}}</div>
<div class="box2"><img src="{{img_http[3]}}" alt="*" /></div>
{%else%}
<div class="description">{{ entry.content|raw }}</div>
<div class="box2"><img src="/default.png" alt="*" /></div>
{%endif%}

Copy code

first it splits the description into an array at the quotes
Then it checks if the 4th element starts with http or /
if it does it splits the description into another array at </a>
and outputs the 2nd element of the description array
it then uses the 4th element of the 1st array as the source for the image tag
or else if there is no image it outputs the whole description and your default image

if it all goes wrong don't blame me :p
2014-06-17 02:11 (edited 2014-06-17 19:49 by Graham ) · (1)
* AH-SID * Graham Thank you very much Sir ;-D
2014-06-17 02:50 · (0)
* Graham This might not work if the images do not have a full http address if you get this problem try testing for / instead of http or maybe both with an "or"
2014-06-17 02:54 (edited 2014-06-17 02:55 by Graham ) · (0)
* Graham Yes it needs that "or"
{% if img_http[3] starts with 'http' or img_http[3] starts with '/' %}
2014-06-17 08:40 · (0)

Online: Guests: 1