Categories > TinyButStrong general >

I'm Sure This is Possible...

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Maz
Date: 2005-11-11
Time: 01:30

I'm Sure This is Possible...

I'm pretty sure this is possible, maybe via a custom function, but I can't seem to get my head around it.

I have an array which I am merging with the template:

$qry = "    SELECT p.agreement_id, p.agreement_title, count( product_id) as usecount
            FROM ".INV_PREFIX."product_agreements p
            LEFT OUTER JOIN ic_products i
            ON p.agreement_id = i.product_agreement
            WHERE p.owner_id = ".$mbr_config['id']."
            GROUP BY p.agreement_id, p.agreement_title";

$agreements = $db->get_results($qry, ARRAY_A);

$TBS->MergeBlock('agreements',$agreements);

TEMPLATE:

                                <tr>
                                    <td class="light">[agreements.agreement_title;noerr;block=tr]</td>
                                    <td class="light">[agreements.usecount;noerr] Products</td>
                                    <td class="dark alignright"><a href="#">Edit</a> | <a href="#">Delete</a></td>
                                </tr>

What I want to do is, if the agreements.usecount >0 then disable the "Delete" link for that row as products are currently using that agreement. So just have it show "Delete" as opposed to <a href="#">Delete</a>

Any pointers on the easiest way to accomplish this?

By: Maz
Date: 2005-11-11
Time: 03:16

Re: I'm Sure This is Possible...

As usual, I managed to resolve it by taking a good read through the manual:

[agreements.usecount;if [agreements.usecount]+-0;then 'Delete';else '<a href="#">Delete</a>']