Page 1 of 2

Template Var Changes

Posted: Wed Dec 08, 2010 12:54 am
by Martin
One thing that is inconsistent, and I'm damned if I know why it's been done, is the use of a new enclosing tag in add-ons and some other areas for templates.

It's hard to gauge exactly where the changes apply and where they don't but in the add-ons here's an example of a changed file:

5.5.x version

Code: Select all

<style type="text/css">
TABLE.Inventory TD { padding-right: 10px }
TR.Product TD { border-top: 2px solid gray; padding-top: 5px; padding-bottom: 5px;}
</style>
<table class="OuterPanel">
    <tr>
        <td class="Heading1">%%LNG_InventoryAddonName%%</td>
    </tr>
    <tr>
        <td class="Intro">
          <table class="Inventory">
            <tr>
              <td colspan="2"><strong>%%LNG_ProductName%%</strong></td>
              <td><strong>%%LNG_StockLevel%%</strong></td>
              <td><strong>%%LNG_PendingShip%%</strong></td>
              <td><strong>%%LNG_AverageSold%%</strong></td>
              <td><strong>%%LNG_DepletedOn%%</strong></td>
              <td><strong>%%LNG_OrderPoint%%</strong></td>
              <td><strong>%%LNG_SuggestedQty%%</strong></td>
            </tr>
            %%GLOBAL_InventoryStatus%%            
          </table>
        </td>
    </tr>
</table>

6.x version

Code: Select all

<style type="text/css">
TABLE.Inventory TD { padding-right: 10px }
TR.Product TD { border-top: 2px solid gray; padding-top: 5px; padding-bottom: 5px;}
</style>
<table class="OuterPanel">
    <tr>
        <td class="Heading1">{% lang 'InventoryAddonName' %}</td>
    </tr>
    <tr>
        <td class="Intro">
          <table class="Inventory">
            <tr>
              <td colspan="2"><strong>{% lang 'ProductName' %}</strong></td>
              <td><strong>{% lang 'StockLevel' %}</strong></td>
              <td><strong>{% lang 'PendingShip' %}</strong></td>
              <td><strong>{% lang 'AverageSold' %}</strong></td>
              <td><strong>{% lang 'DepletedOn' %}</strong></td>
              <td><strong>{% lang 'OrderPoint' %}</strong></td>
              <td><strong>{% lang 'SuggestedQty' %}</strong></td>
            </tr>
            {{ InventoryStatus|safe }}            
          </table>
        </td>
    </tr>
</table>

So to summarise:

%%LNG_Foo%% becomes {% lang 'Foo' %}
%%GLOBAL_Bar%% becomes {{ Bar|safe }}

... and before you ask, no I haven't a clue what the "safe" bit is all about... suggestions welcome there :)

Re: Template Var Changes

Posted: Sun Dec 12, 2010 12:33 pm
by CharlieFoxtrot
This one is a mystery to me as well. Even if we set aside the actual reason for the change... the inconsistency of how it's applied is very odd indeed. (Couple that with the apparent lack of documentation... and users are (again) left on their own to make sense of it all.)

Re: Template Var Changes

Posted: Wed Dec 15, 2010 1:47 pm
by Martin
Just had a small nudge towards some information that would help understand what's going on..

Apparently there's a move to a new template system/library called Twig (I'd wondered what that was tbh).
Info on TWIG template system: http://www.twig-project.org/book/02-Twi ... -Designers

In terms of the discrepancies this appears to be a changeover thing with the add-ons starting the ball rolling, then the front end, followed by the administration side of things. That's not hard and fast intel btw, but makes sense..

Thanks for the info'... you know who you are.. :)

Re: Template Var Changes

Posted: Thu Dec 16, 2010 3:05 pm
by Tony Barnes
Interesting - haven't played with 6.x yet, so hadn't spotted.

I do have to wonder why they are moving to another system though, this one works fine!!

Re: Template Var Changes

Posted: Thu Dec 16, 2010 3:43 pm
by Martin
Tony Barnes wrote:Interesting - haven't played with 6.x yet, so hadn't spotted.

I do have to wonder why they are moving to another system though, this one works fine!!
I suspect it's got something to do with greater flexibility in how the markup is used similar to the Smarty lib.

Re: Template Var Changes

Posted: Sun Dec 19, 2010 6:34 pm
by Brandeline
The thing that bothers me, on looking over the Twig examples at the provided link, is that it seems a bit of a step backward towards mixing the programming into the markup. I hope they don't go too far in that direction. It was kind of nice to have all the logic separate from the templates themselves.

Re: Template Var Changes

Posted: Thu Jan 06, 2011 12:18 am
by meules
I think they going to use this for feature addons. Maybe like multiple languages??

Re: Template Var Changes

Posted: Tue Jan 11, 2011 10:44 pm
by Martin
meules wrote:I think they going to use this for feature addons. Maybe like multiple languages??
Maybe, although they could have handled multiple languages from the outset if the specification had been written properly from the outset and not patched together as they went along.

Template/language fields have never been properly implemented with hard coded labels appearing all over the place so that would need to change before they could get proper language support added in.

Re: Template Var Changes

Posted: Thu May 26, 2011 1:09 pm
by pitorian
Hi Martin, do you have any updates on this, or what files to modify in the template to edit, as there is no indication for us newbie isc messing around with the store code fools like me, :-)

Thanks Chris

Re: Template Var Changes

Posted: Thu May 26, 2011 1:16 pm
by Martin
pitorian wrote:Hi Martin, do you have any updates on this, or what files to modify in the template to edit, as there is no indication for us newbie isc messing around with the store code fools like me, :-)
From what I remember it was more the stuff in the backend (ie: admin modules, etc...) that had changes to their templates. I had to modify the templates for the Royal Mail module for example.

Front end (customer facing) didn't seem to get any changes... In reality all that changed was the way the templates were parsed (ie: tag changed for actual language values) so unless you are seeing templates with missing bits of text, you should be fine.