Zen Cart Logo

tpl_divular_display

Locked

Views: 1,585

Results 1 to 5 of 5
This thread is locked. New replies are disabled.
13 Dec 2006, 5:15 PM
#1
loque avatar

loque

New Zenner

Join Date:
Dec 2006
Posts:
12
Plugin Contributions:
0

tpl_divular_display

Hi all,

My first post and working on my first zencart project, really loving it at the moment (dont think this feeling will fade!). I have to say a big thank-you first to everyone who has worked and helped with zencart as I am finding it very intuitive and well put together, including the documentation.

As the title describes I am trying to build a 'div' based template, I am currently modifying tpl_tabular_display.php (copied as tpl_divular_display.php) and have a feeling it may get messy as i edit the th/td inserts. Has anyone tried doing this before? Can anyone help me?

Thanks!
Loque

13 Dec 2006, 5:21 PM
#2
loque avatar

loque

New Zenner

Join Date:
Dec 2006
Posts:
12
Plugin Contributions:
0

Re: tpl_divular_display

Ok, that was very easy, still working on it, but basically...

I am php noobie so that was a pretty lucky guess (I'll put it down to zencart being so good).

<?php
/**
 * Common Template - tpl_divular_display.php
 *
 * This file is used for generating divular output where needed, based on the supplied array of table-cell contents.
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @original version $Id: tpl_tabular_display.php 3957 2006-07-13 07:27:06Z drbyte $
 * @modified by Loque 2006-12-13
 */

//print_r($list_box_contents);
  $cell_scope = (!isset($cell_scope) || empty($cell_scope)) ? 'col' : $cell_scope;
  $cell_title = (!isset($cell_title) || empty($cell_title)) ? 'list' : $cell_title;

?>
<div id="<?php echo 'cat' . $cPath . 'Table'; ?>" class="tabTable">
<?php
  for($row=0; $row<sizeof($list_box_contents); $row++) {
    $r_params = "";
    $c_params = "";
    if (isset($list_box_contents[$row]['params'])) $r_params .= ' ' . $list_box_contents[$row]['params'];
?>
  <div<?php echo $r_params; ?>>
<?php
    for($col=0;$col<sizeof($list_box_contents[$row]);$col++) {
      $c_params = "";
      $cell_type = ($row==0) ? 'div' : 'div';
      if (isset($list_box_contents[$row][$col]['params'])) $c_params .= ' ' . $list_box_contents[$row][$col]['params'];
      if (isset($list_box_contents[$row][$col]['text'])) {
?>
   <?php echo '<' . $cell_type . $c_params . '>'; ?><?php echo $list_box_contents[$row][$col]['text'] ?><?php echo '</' . $cell_type . '>'  . "\n"; ?>
<?php
      }
    }
?>
  </div>
<?php
  }
?> 
</div>
13 Dec 2006, 5:29 PM
#3
kim avatar

kim

Obaa-san

Join Date:
Jun 2003
Posts:
26,591
Plugin Contributions:
0

Re: tpl_divular_display

This is probably a silly question, but the tabular builds the table to display tabular information, why change that?

13 Dec 2006, 5:39 PM
#4
loque avatar

loque

New Zenner

Join Date:
Dec 2006
Posts:
12
Plugin Contributions:
0

Re: tpl_divular_display

I have been given a design that places the products in a non-tabular format, breaking the use of a table for displaying the products.

It also singles out the first product displaying it differently to the others. So this is my next challenge :¬| (if it becomes to tricky i will just hand it back to the designer and let him know of the restrictions)

13 Dec 2006, 5:56 PM
#5
loque avatar

loque

New Zenner

Join Date:
Dec 2006
Posts:
12
Plugin Contributions:
0

Re: tpl_divular_display

Ok, this seems to work on my last point,

<?php
/**
 * Common Template - tpl_divular_display.php
 *
 * This file is used for generating divular output where needed, based on the supplied array of table-cell contents.
 *
 * @package templateSystem
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @original version $Id: tpl_tabular_display.php 3957 2006-07-13 07:27:06Z drbyte $
 * @modified by Loque 2006-12-13
 */

//print_r($list_box_contents);
  $cell_scope = (!isset($cell_scope) || empty($cell_scope)) ? 'col' : $cell_scope;
  $cell_title = (!isset($cell_title) || empty($cell_title)) ? 'list' : $cell_title;

?>
<div id="<?php echo 'cat' . $cPath . 'Table'; ?>" class="tabTable">
<?php
  for($row=1; $row<sizeof($list_box_contents); $row++) { // modified to exclude the headings... 
    $r_params = "";
    $c_params = "";
    if (isset($list_box_contents[$row]['params'])) $r_params .= ' ' . $list_box_contents[$row]['params'];
?>
  <div<?php echo $r_params; ?> <?php echo 'id="productList' . $row . '"'  ?>>
<?php
    for($col=0;$col<sizeof($list_box_contents[$row]);$col++) {
      $c_params = "";
      $cell_type = ($row==0) ? 'div' : 'div';
      if (isset($list_box_contents[$row][$col]['params'])) $c_params .= ' ' . $list_box_contents[$row][$col]['params'];
      if (isset($list_box_contents[$row][$col]['text'])) {
?>
   <?php echo '<' . $cell_type . $c_params . '>'; ?><?php echo $list_box_contents[$row][$col]['text'] ?><?php echo '</' . $cell_type . '>'  . "\n"; ?>
<?php
      }
    }
?>
  </div>
<?php
  }
?> 
</div>
```outputs to this;

```html
<div id="cat65Table" class="tabTable">
  <div class="productListing-odd" id="productList1">
   <div class="productListing-data"><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=182"><img src="images/blank.png" alt="CREST" title=" CREST " width="100" height="80" class="listingProductImage" /></a></div>
   <div class="productListing-data">30</div>
   <div class="productListing-data"><h3 class="itemTitle"><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=182">CREST</a></h3><div class="listingDescription">165G 100% COMBED COTTON JERSEY PRINT ON FRONT AND BACK</div></div>
   <div class="productListing-data">£25.00<br /><br /><a href="http://yoursite.net//shop/index.php?main_page=index&cPath=65&sort=20a&action=buy_now&products_id=182"><img src="includes/templates/template_default/buttons/english/button_buy_now.gif" alt="Buy Now" title=" Buy Now " width="60" height="15" class="listingBuyNowButton" /></a><br /><br /></div>
  </div>
  <div class="productListing-even" id="productList2">
   <div class="productListing-data"><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=183"><img src="images/blank.png" alt="RETRO LOGO" title=" RETRO LOGO " width="100" height="80" class="listingProductImage" /></a></div>
   <div class="productListing-data">30</div>
   <div class="productListing-data"><h3 class="itemTitle"><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=183">RETRO LOGO</a></h3><div class="listingDescription">165G 100% COMBED COTTON JERSEY PRINT ON FRONT AND BACK</div></div>
   <div class="productListing-data">£25.00<br /><br /><a href="http://yoursite.net//shop/index.php?main_page=index&cPath=65&sort=20a&action=buy_now&products_id=183"><img src="includes/templates/template_default/buttons/english/button_buy_now.gif" alt="Buy Now" title=" Buy Now " width="60" height="15" class="listingBuyNowButton" /></a><br /><br /></div>
  </div>
  <div class="productListing-odd" id="productList3">
   <div class="productListing-data"><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=181"><img src="images/blank.png" alt="ROOTS" title=" ROOTS " width="100" height="80" class="listingProductImage" /></a></div>
   <div class="productListing-data">30</div>
   <div class="productListing-data"><h3 class="itemTitle"><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=181">ROOTS</a></h3><div class="listingDescription">160G 100% COTTON JERSEY PRINT ON FRONT AND ARM</div></div>
   <div class="productListing-data">£25.00<br /><br /><a href="http://yoursite.net//shop/index.php?main_page=index&cPath=65&sort=20a&action=buy_now&products_id=181"><img src="includes/templates/template_default/buttons/english/button_buy_now.gif" alt="Buy Now" title=" Buy Now " width="60" height="15" class="listingBuyNowButton" /></a><br /><br /></div>
  </div>
  <div class="productListing-even" id="productList4">
   <div class="productListing-data"><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=180"><img src="images/blank.png" alt="SKATER 1989" title=" SKATER 1989 " width="100" height="80" class="listingProductImage" /></a></div>
   <div class="productListing-data">30</div>
   <div class="productListing-data"><h3 class="itemTitle"><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=180">SKATER 1989</a></h3><div class="listingDescription">160G 100% COTTON JERSEY PRINT ON FRONT AND BACK</div></div>
   <div class="productListing-data">£25.00<br /><br /><a href="http://yoursite.net//shop/index.php?main_page=product_info&cPath=65&products_id=180">... more info</a><br /><br /></div>
  </div>
</div>

I am probably doing something silly somewhere :¬)