V
V
Vyacheslav2011-06-06 13:50:38
Template Engines
Vyacheslav, 2011-06-06 13:50:38

template engine

Hello.
I would like to implement a system of templates for sections of the site.

For example, there are 3 news sections (headline, announcement, full news, date). It is necessary for everyone to make their own template for displaying a list of news, viewing the full news, and let's say output somewhere in a column.

In addition, each template must be unique. Somewhere, for example, it is not required to display the date, somewhere it is required to make a link to the title, somewhere to the announcement, and so on ... As a result, for one news section there are 3 different templates. It is desirable that in the template it was possible to write some minimum conditions.

I would like the template to be stored in the database (I know that this is evil, but let's say if there are not 3 sections but 30 and for each 3 of its templates there are a total of 90 files)

Tried to use tinyButStrong - interesting but not very good in some things.

Or is it still worth using files and some of the common template engines?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Arthur Koch, 2011-06-06
@dudeonthehorse

And why not write the conditions at the output? etc.
if($date){echo $date}
if($link){echo'$title';}else{echo $title;}

V
Vyacheslav, 2011-06-06
@Lomiren

When deriving what?
I want the layout designer to write in the admin panel:
- Template 1 - {date} {title}
{anons}
- - Template 2 - {title}
{if image}

{else}

{end if}
{anons}
Further more
- - Template 3 - {date}
{anons}
----------

V
Vyacheslav, 2011-06-06
@Lomiren

So it will be clearer


— Шаблон 1 —
<div class="news">
<b>{date}</b>
{if link}
    <a href="{link}">{title}</a>
{else}
    {title}
{end if}

{anons}
</div>

 —  Шаблон 2 —
<div class="stat">
{title}
{if image}
    <img src="{image}"/>
{else}
    <img src="empty.jpg"/>
{end if}
{anons}
<a href="{link}">Дальше больше</a>
</div>

 —  Шаблон 3 —
<div class="other">
{date}

<a href="{link}">{anons}</a>
</div>

S
sergeyvolobuev, 2011-06-06
@sergeyvolobuev

you definitely need Blitz

V
Vyacheslav, 2011-06-15
@Lomiren

Found the optimal solution - Twig

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question