I have an ATK-Framework which I'm inheriting from a previous (departed) developer, and I'm finding the documentation to be sparse and poorly structured.
We have a subscription system where customer register an account, and then there can be multiple subscriptions on that account. The classes for accounts and subscriptions inherit from atkNode.
I want to be able to highlight a row in a table of subscriptions so that it is easier to see, at a glance, when a particular subscription has expired. The expiry date of the subscription is already a property of that n开发者_如何学Pythonode.
I can easily find the code where the node is created in the framework's modules - but try as hard as I can, I can't find any corresponding HTML template to display this information, and so can't find anyway to add in the required logic to highlight these rows.
-- Update:
After some more clicking around, I've found the templates - they're in the main ATK framework directory (including the custom templates that my predecessor has created).
They appear to be smarty-like templates, so modifying/extending them shouldn't be too hard.
--
So, I found the following in the template:
{foreach from=$rows item=row}
<tr id="{$row.id}" class="row{if $row.rownum % 2 == 0 }1{else}2{/if}" {if $row.background!=""}style="background-color:{$row.background}" {/if}
onmouseover="highlightrow(this, '{$row.highlight}')"
onmouseout="resetrow(this)"
onclick="selectrow(this, '{$listid}', {$row.rownum})">
{section name=colloop loop=$row.cols}
<{if $row.type == "subtotal"}th{else}td{/if}
class="{if $smarty.section.colloop.index===0}recordListTdFirst{else}recordListTd{/if}{if $row.cols[colloop].type == "data"} clickable{/if}"
valign="{$vorientation}" {if isset($row.cols[colloop].htmlattributes)}{$row.cols[colloop].htmlattributes}{/if}
{if $row.cols[colloop].type == "data"} onclick="rl_try('{$listid}', event, {$row.rownum}, ['select', 'edit', 'view'], false);"{/if}>
{if $row.cols[colloop].content != ""}{$row.cols[colloop].content}{else} {/if}
</{if $row.type == "subtotal"}th{else}td{/if}>
{/section}
</tr>
{/foreach}
I'm guessing that $row and $cols are set by the class...
There's a couple of problems - this recordlist.tpl is a generic template. This means that I can't just jam a check for the expiry date at this point.
Is there a way to override this template for one specific node/recordset?
I downloaded the ATK zip and as you said, it appears to just be smarty (atk/ui/smarty), if you can throw the template tag {debug} into your template anywhere you should get a smarty debug window, in which you can see how the arrays/objects have been assigned/structured in the smarty template engine.
If the property has been assiend to the row focus on {$row.X} if the property is against the column focus on {$row.cols[colloop].X}, if the date is a unix timestamp you should be able to do
class="row{if $row.rownum % 2 == 0 }1{else}2{/if}{if $row.timestamp_var < $smarty.now} your_class_name{/if}"
for a simple date comparison.
精彩评论