Categories > TinyButStrong general >

More Alternating Row Issues

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

More Alternating Row Issues

I'm sure there is something about alternating rows that I'm just not getting but here's the problem.

the main issue is in the template with this piece:

                            <tr>
                                <td class="dark alignright" colspan="6">[pending;block=tr]
                                    <input type="submit" class="button" name="btn_pending" id="btn_pending" value="Process Selected Items" />
                                </td>
                            </tr>
                            <tr>
                                <td class="dark alignleft" colspan="6">[pending;block=tr;nodata]
                                    [lang.cell_no_results
                                </td>
                            </tr>

It works great so long as more than one record is returned or no records are returned. If there is only one record,

Here's the complete code. (Apologies for it being so lengthy)

Main Code:

else
{
    //------------------------------------
    // Load tmpl and initialise vars
    //------------------------------------
    $TBS->LoadTemplate('content/modules/admin/pending-products');
   
    $product_action     = array();
    $filter_category     = array();
    $filter_status         = array();
    $filter_booked_to    = array();
    $pending_products    = array();
   
    //------------------------------------
    // Default filter-by values
    //------------------------------------
    $filter['status'] = 1;
    $filter['category'] = 1;
   
    //------------------------------------
    // Build product action list
    //------------------------------------
    $product_action[]    = array('act' =>'Acknowledge Receipt',        'id'=>"1");
    $product_action[]    = array('act' =>'Take for Testing',            'id'=>"2");
    $product_action[]    = array('act' =>'Return as Faulty',            'id'=>"3");
    $product_action[]    = array('act' =>'Return as Unsuitable',        'id'=>"4");
   
    //------------------------------------
    // Build template filter (By Status) list
    //------------------------------------
    $filter_status[]    = array('act' =>'Not Actioned',                'id'=>"0");
    $filter_status[]    = array('act' =>'Acknowledge Receipt',        'id'=>"1");
    $filter_status[]    = array('act' =>'Take for Testing',            'id'=>"2");
    $filter_status[]    = array('act' =>'Return as Faulty',            'id'=>"3");
    $filter_status[]    = array('act' =>'Return as Unsuitable',        'id'=>"4");
   
    //------------------------------------
    // Build administrator template list
    //------------------------------------
    $admins = $objStore->get_admins();
   
    // Did class function return an array?
    if(!empty($admins))
    {
        foreach ($admins as $admin)
        {
            $filter_booked_to[]    = array('act' => $admin['members_display_name'], 'id'=> $admin['id']);
        }
       
        // Append to end of array. (Will be used in class function)
        $filter_booked_to[]    = array('act' => 'Anyone', 'id'=> 999999);
    }
       
    //------------------------------------
    // Get product cats for filter list
    //------------------------------------
    $cats = $objStore->get_categories();
   
    // Did class function return an array?
    if(!empty($admins))
    {
        foreach ($cats as $cat)
        {
            $filter_category[]    = array('act' => $cat['cat_name'], 'id'=> $cat['cat_id']);
        }
    }
   
    // Append to end of array. (Will be used in class function)
    $filter_category[]    = array('act' => 'All Categories', 'id'=> 999999);
   
    //-----------------------------------------
    // Filter form submitted
    //-----------------------------------------
   
    // *** Note: Add the GPC Cleaning Data! *** //
   
    if (isset($icube->vars_post['gpc_filter']))
    {
        $filter['status'] = $icube->vars_post['filter_status'];
        $filter['category'] = $icube->vars_post['filter_category'];
    }

    $pending_products = $objStore->get_pending_products($filter);
   
    //-----------------------------------------
    // Action form submitted
    //-----------------------------------------
   
    // *** Note: Add the GPC Cleaning Data! *** //
   
    $validate->validate_types($icube->vars_post, array('gpc_click' => 'INT'));
       
    if (isset($icube->vars_post['gpc_click']))
    {
        //--------------------------------------------
        // Check to see if check boxes were checked
        //--------------------------------------------
        if(!empty($icube->vars_post['allbox']))
        {
            foreach ($icube->vars_post['allbox'] as $key => $value)
            {
                // Not  very efficient but there are never going to be a huge
                // number of records here
               
                $query = "    UPDATE ".INV_PREFIX."products
                            SET product_state=".$icube->vars_post['product_state'][$key]."
                            WHERE product_id = ".$value."";
                           
                $rs = $db->query($query);
            }
        }
    }
}

$TBS->MergeBlock('action1,action2', $product_action);
$TBS->MergeBlock('filter_category,', $filter_category);
$TBS->MergeBlock('filter_status', $filter_status);
$TBS->MergeBlock('filter_booked_to', $filter_booked_to);
$TBS->MergeBlock('pending', $pending_products);
$TBS->MergeBlock('err_msg', $validate->err_msg);
$TBS->Show();

Template:

    [onload;file=templates/[var.mbr_config.theme]/layout/sidebar-admin.tpl.php]
    <div id="contentColumn">
        <div id="innerContentColumn">
            <h1>InvisionCube Admin - Pending Products</h1>
            <p class="leader">Products contained within this area require staff attention.</p>
            <h2>Products Awaiting Attention</h2>

            <div class="buttonbar">
                <form action="[var..script_name]" method="post" id="form_search" name="form_search">
                    <input type="hidden" name="gpc_filter" id="gpc_filter" value="1" />
                    <label for="joined">Show</label>
                    <select class="select" name="filter_category" id="filter_category">
                        <option value="[filter_category.id]">[filter_category.act;block=option;noerr]</option>
                        <option>[var.filter.category;selected]</option>
                    </select>
                    <label for="posts">with status</label>
                    <select class="select" name="filter_status" id="filter_status">
                        <option value="[filter_status.id]">[filter_status.act;block=option;noerr]</option>
                        <option>[var.filter.status;selected]</option>
                    </select> 
                    <label for="inactive">booked out to</label>
                    <select class="select" name="filter_booked_to" id="filter_booked_to">
                        <option value="[filter_booked_to.id]">[filter_booked_to.act;block=option;noerr]</option>
                    </select>
                    <input type="submit" class="button" id="btn_sort" name="btn_sort" value="Filter" />
                </form>
            </div>
           
            <p><span class="notify">[var.success_msg;magnet=p;noerr]</span></p>
            <div id="errorshow">[onshow;block=div;when [err_msg;noerr]!='']
            [err_msg;block=begin]
            <p class="errortext">[err_msg.val;magnet=p;htmlconv=no]</p>
            [err_msg;block=end]
            </div>
            <div class="tablewrapper">[onshow;block=div;when [pending;noerr]!='']
                <form action="[var..script_name]" method="post" id="pending">
                    <fieldset>
                        <input type="hidden" name="gpc_click" id="gpc_click" value="1" />
                        <table cellspacing="1" cellpadding="5" summary="List of products which are available for moderator preview">
                            <tr>
                                <th>Title</th>
                                <th>Author</th>
                                <th>Submitted</th>
                                <th>Category</th>
                                <th>Action</th>
                                <th class="aligncenter"><input type="checkbox" name="checkAll" id="checkAll" onclick="checkAllFields(1);" /></th>
                            </tr>
                            <tr>
                                <td class="light">[pending.product_title;noerr]</td>
                                <td class="light">[pending.name;noerr]</td>
                                <td class="light">[pending.product_date;frm='ddxx mmmm';noerr]</td>
                                <td class="light">[pending.cat_name;block=tr;noerr]</td>
                                <td class="light">
                                    <select class="select" name="product_state[]" id="product_state[]">
                                        <option value="[action1.id]">[action1.act;block=option;noerr]</option>
                                    </select>
                                </td>
                                <td class="light aligncenter">
                                    <input type="checkbox" name="allbox[]" id="allbox[]" value="[pending.product_id]" />
                                </td>
                            </tr>
                            <tr>
                                <td class="dark" colspan="6">[pending;block=tr;nodata][lang.cell_no_results]</td>
                            </tr>
                            <tr>
                                <td class="dark">[pending.product_title]</td>
                                <td class="dark">[pending.name]</td>
                                <td class="dark">[pending.product_date;frm='ddxx mmmm']</td>
                                <td class="dark">[pending.cat_name;block=tr]</td>
                                <td class="dark">
                                    <select class="select" name="product_state[]" id="product_state[]">
                                        <option value="[action2.id]">[action2.act;block=option]</option>
                                    </select>
                                </td>
                                <td class="dark aligncenter">
                                    <input type="checkbox" name="allbox[]" id="allbox[]" value="[pending.product_id]" />
                                </td>
                            </tr>
                            <tr>
                                <td class="dark alignright" colspan="6">[pending;block=tr]
                                    <input type="submit" class="button" name="btn_pending" id="btn_pending" value="Process Selected Items" />
                                </td>
                            </tr>
                            <tr>
                                <td class="dark alignleft" colspan="6">[pending;block=tr;nodata]
                                    [lang.cell_no_results
                                </td>
                            </tr>
                        </table>
                    </fieldset>
                </form>
            </div>
        </div>
    </div>

What am I missing? I'm sure it's something really simple and stupid but I'm just not getting it.
By: Skrol29
Date: 2005-11-28
Time: 02:09

Re: More Alternating Row Issues

Hello Maz,

You've forgotten to describe what's going wrong with this template.
But I see two things:

1/ The last TBS tag is not closed
 
[lang.cell_no_results
   But this has probably nothing to do with your problem.

2/ You have 3 alternated sections for block "pending".
  The third one seems to be a footer of record or something like this.
  Any way, with the current template, the third record of the $pending_products array is never displayed. It has a section with a "Process Selected Items" button instead.

And by the way, having two sections with parameter "nodata" is useless.
Only one is taken in acount.