Template Var Changes

For articles specific to version 6.x
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Template Var Changes

Post 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 :)
CharlieFoxtrot
Confirmed
Confirmed
Posts: 413
Joined: Sun Aug 09, 2009 1:23 pm

Re: Template Var Changes

Post 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.)
ISC 4.0.7

"... and let's be honest that whole "by design" thing is getting old too."
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: Template Var Changes

Post 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.. :)
Tony Barnes
Posts: 744
Joined: Thu Jun 18, 2009 8:59 am

Re: Template Var Changes

Post 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!!
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: Template Var Changes

Post 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.
Brandeline
Posts: 76
Joined: Thu Sep 16, 2010 4:12 am

Re: Template Var Changes

Post 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.
meules
Confirmed
Confirmed
Posts: 95
Joined: Wed Jun 17, 2009 8:56 pm
Location: NL

Re: Template Var Changes

Post by meules »

I think they going to use this for feature addons. Maybe like multiple languages??
ISC v6
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: Template Var Changes

Post 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.
pitorian
Posts: 31
Joined: Mon Aug 17, 2009 9:55 am

Re: Template Var Changes

Post 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
Martin
Site Admin
Site Admin
Posts: 1854
Joined: Wed Jun 17, 2009 6:30 pm
Location: South Yorkshire UK
Contact:

Re: Template Var Changes

Post 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.
Post Reply