Welcome Guest, Not a member yet? Register   Sign In
Which template system should I use ?
#9

[eluser]EugeneS[/eluser]
i thought about this a lot of time and have come to idea that any tamplate engine is just useless with the CI and MVC (in general)

just use alternate PHP syntax in your views .... do not use OOP in views, only simple variables, arrays with the "human friendly" names and keys.

with this limitations, as you can see below, view looks exactly like template but works really faster ) more over your php editor vill highlight alternate PHP syntax and this template will be easy to modify.

just adopt that template delimiters are: <? ?>
to show variables delimiters: <?=;?>
logic constructions:
<? if(): ?>
<? else: ?>
<? endif; ?>

its really looks like template engine .... right Wink so what the sense of template engine instead of views Wink

so your view will look like:

Code:
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="padding-left:7px; padding-right:7px">
<tr>
    <td>
        <h1>Корзина</h1>
        <p><a href="&lt;?=$site_url;?&gt;">Начало</a> &raquo; <a href="&lt;?=$site_url;?&gt;/cart/">Корзина</a></p>
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
    &lt;? if(isset($cart_arr) && count($cart_arr) > 0): ?&gt;
        &lt;form action="&lt;?=$site_url;?&gt;/cart/update" method="post"&gt;
        <tr>
            <td><h2>Товар</h2></td>
            <td width="100"><h2>Количество</h2></td>
            <td width="50"><h2>Операция</h2></td>
        </tr>
        <tr>
            <td colspan="3" style="padding:0;">
                <hr>
            </td>
        </tr>
        &lt;? foreach($cart_arr as $prod_id => $prod_details): ?&gt;
        <tr>
            <td class="small">&lt;?=$prod_details['Name'];?&gt;</td>
            <td valign="top">&lt;input type="text" name="item[&lt;?=$prod_id;?&gt;]" value="&lt;?=$prod_details['Number'];?&gt;" size="8" maxlength="6" class="input"&gt;</td>
            <td valign="top"><a href="&lt;?=$site_url;?&gt;/cart/delete/&lt;?=$prod_id;?&gt;" class="podmenu">Выложить</a></td>
        </tr>
        &lt;? endforeach; ?&gt;
        <tr>
            <td colspan="3" style="padding:0;">
                <hr>
            </td>
        </tr>
        <tr>
            <td class="text" colspan="3">
                Количество: <b>&lt;?=$prod_count;?&gt;</b> шт. на сумму: <b>&lt;?=$prod_cost;?&gt;</b> руб.
            </td>
        </tr>
        <tr>
            <td colspan="3" style="padding:0;">
                <hr>
            </td>
        </tr>
        <tr>
            <td style="padding:0;" align="left">
                &lt;? if(isset($referrer)): ?&gt;
                    &lt;input type="button" value="&lt;< Продолжить покупку" onClick="location.href='&lt;?=$referrer;?&gt;'"&gt;
                &lt;? endif; ?&gt;
            </td&gt;
            <td colspan="2" style="padding:0;" align="right">
                &lt;input type="submit" value="Пересчитать"&gt;
            </td>
        </tr>
        &lt;/form&gt;
...............


Messages In This Thread
Which template system should I use ? - by El Forum - 10-09-2007, 03:52 PM
Which template system should I use ? - by El Forum - 10-09-2007, 06:02 PM
Which template system should I use ? - by El Forum - 10-09-2007, 07:51 PM
Which template system should I use ? - by El Forum - 10-09-2007, 08:07 PM
Which template system should I use ? - by El Forum - 10-09-2007, 08:14 PM
Which template system should I use ? - by El Forum - 10-09-2007, 09:44 PM
Which template system should I use ? - by El Forum - 10-10-2007, 01:21 AM
Which template system should I use ? - by El Forum - 10-10-2007, 05:11 AM
Which template system should I use ? - by El Forum - 10-10-2007, 07:46 AM
Which template system should I use ? - by El Forum - 10-10-2007, 09:22 AM
Which template system should I use ? - by El Forum - 10-10-2007, 09:47 AM
Which template system should I use ? - by El Forum - 10-10-2007, 09:51 AM
Which template system should I use ? - by El Forum - 10-10-2007, 10:53 AM
Which template system should I use ? - by El Forum - 10-10-2007, 11:56 AM
Which template system should I use ? - by El Forum - 10-10-2007, 12:03 PM
Which template system should I use ? - by El Forum - 10-10-2007, 12:23 PM
Which template system should I use ? - by El Forum - 10-10-2007, 12:28 PM
Which template system should I use ? - by El Forum - 10-10-2007, 12:36 PM
Which template system should I use ? - by El Forum - 10-10-2007, 01:40 PM
Which template system should I use ? - by El Forum - 10-10-2007, 01:57 PM
Which template system should I use ? - by El Forum - 10-12-2007, 09:30 AM
Which template system should I use ? - by El Forum - 10-12-2007, 01:53 PM
Which template system should I use ? - by El Forum - 10-20-2007, 03:43 AM
Which template system should I use ? - by El Forum - 10-20-2007, 11:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB