Displaying items in shop


  -----  
Author Message

laisvai
Member

Sun Sep 10, 2006 7:01 am   Post subject: Displaying items in shop
Hi,
How can i get items displayed on particular shop inventory page, let's say instead of describing it link? right now i can see picture only if i click on item description, so users has to click on all items separately if he wants to look at it. It would be much comfortable if he can see all items displayed and decide what to buy more effectively (click on image, not link to go to sell/buy dialog).
Thanks
 

Thoul
Administrator

Sun Sep 10, 2006 11:35 pm   Post subject: re: Displaying items in shop
That sounds like a good application of the per-shop template feature. I'm too tired to go into much detail on it right now, but I'll see what I can do tomorrow.
 

Thoul
Administrator

Mon Sep 11, 2006 11:32 am   Post subject: re: Displaying items in shop
Here is what you should do to accomplish this.
  1. Make a copy of templates/xxxx/shop/shop_list_body.tpl. Give it a new name like shop_list_body2.tpl, or whatever.
  2. In the admin panel, find and edit the shop. Change the "Main Template" field to the name of your new tpl file. This shop will now use that tpl file, so you can edit it to customize this shop.
  3. Do these steps in shop_inventory.php:

    Code:

    #
    #-----[ FIND ]--------------------------------------
    #

          $template->assign_block_vars('listrow', array(

    #
    #-----[ BEFORE, ADD ]--------------------------------------
    #

          if (@file_exists("shop/images/".$row2['name'].".jpg"))
          {
             $itemfilext = "jpg";
          }
          elseif (@file_exists("shop/images/".$row2['name'].".png"))
          {
             $itemfilext = "png";
          }
          else
          {
             $itemfilext = "gif";
          }

    #
    #-----[ FIND ]--------------------------------------
    #

             'NAME' => $row2['name'],

    #
    #-----[ AFTER, ADD ]--------------------------------------
    #

             'BUY_URL' => append_sid('shop_bs.'.$phpEx.'?action=buy&item='.$row2['id'], true),
             'FILE_EXT' => $itemfilext,

    #
    #-----[ FIND ]--------------------------------------
    #

          'L_ITEM_NAME' => $lang['name'],

    #
    #-----[ AFTER, ADD ]--------------------------------------
    #

          'L_ICON' => $lang['icon'],


  4. Do these steps in the new tpl file:

    Code:

    #
    #-----[ FIND ]--------------------------------------
    #

         <td class="row3" nowrap="nowrap"><span class="gen"><b>{L_ITEM_NAME}</b></span></td>

    #
    #-----[ BEFORE, ADD ]--------------------------------------
    #

         <td class="row3" nowrap="nowrap"><span class="gen"><b>{L_ICON}</b></span></td>

    #
    #-----[ FIND ]--------------------------------------
    #

         <td class="{listrow.ROW_CLASS}"><span class="gensmall"><a href="{listrow.URL}" alt="{listrow.NAME}" title="{L_ITEM_INFO} {listrow.NAME}" class="gensmall"><b>{listrow.NAME}</b></a></span></td>

    #
    #-----[ BEFORE, ADD ]--------------------------------------
    #

         <td class="{listrow.ROW_CLASS}"><span class="gensmall"><a href="{listrow.BUY_URL}" alt="{listrow.NAME}" title="{L_ITEM_INFO} {listrow.NAME}" class="gensmall"><img src="shop/images/{listrow.NAME}.{listrow.FILE_EXT}" border="0"></a></span></td>


And then you should have the images displaying in the shop listing, with the images being a clickable link to buy the item. If you want, you can even customize the tpl more to change the display of this one shop.
 

laisvai
Member

Wed Sep 13, 2006 3:36 pm   Post subject:
Oh thanks, going to do this right now Smile
 

laisvai
Member

Wed Sep 13, 2006 4:24 pm   Post subject:
Everything works just great Shocked
i even didn't know if there is a possibility to choose template, now i can customize it as i want Smile

Thank you for your time Smile
 

Thoul
Administrator

Wed Sep 13, 2006 4:29 pm   Post subject: re: Displaying items in shop
Glad you like it. Have fun with it! Very Happy
 

laisvai
Member

Sun Oct 15, 2006 11:50 am   Post subject:
Hello,
i need help once again.
It's regarding items display, i wanna to show them not in one column, but for example in 5 columns, i played a liitle with shop bar addon, look what i done, i also want something like this to do for my other shops:



Problem which i can't solve (sit 2 hours already with this Confused ) is how to make next row of pictures?

Here is my code for shop_bar.php

Code:

   $template->set_filenames(array(
      'body' => 'shop/shop_bar_body.tpl')
   );

   $sql = "SELECT a.*
      FROM " . SHOP_ITEMS_TABLE . " a, " . SHOP_TABLE . " b
      WHERE b.url = 'shop_bar.php'
         AND a.shop = b.shopname";
   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, "Error getting alcohols!", '', __LINE__, __FILE__, $sql);
   }
   $sql_count = $db->sql_numrows($result);
   if ( $sql_count )
   {
      for ($i = 0; $i < $sql_count; $i++)
      {
         if (!( $row = $db->sql_fetchrow($result) ))
         {
            message_die(GENERAL_ERROR, "Error getting alcohols!", '', __LINE__, __FILE__, $sql);
         }

         $rownum = ( $i % 2 ) ? "row1" : "row2";

         if ( $row['sdesc'] < 0 )
         {
            $duration = '-' . duration($row['sdesc'] * -1);
         }
         else
         {
            $duration = ( !is_numeric($row['sdesc']) || $row['sdesc'] < 1 ) ? $lang['bar_none'] : duration($row['sdesc']);
         }

         $template->assign_block_vars('list_items', array(
            'ROW_CLASS' => $rownum,
            'ITEM_URL' => append_sid("shop_bar.php?action=buy&item_id=" . $row['id']),
            'ITEM_NAME' => $row['name'],
            'ITEM_DESC' => $row['ldesc'],
            'ITEM_LENGTH' => $duration,
            'ITEM_COST' => $row['cost'],
            'ITEM_STOCK' => $row['stock'])
         );
      }
   }


and shop_bar_body.tpl :

Code:

  <table width="100%" cellpadding="4" cellspacing="1" border="0" align="center" class="forumline">
   <tr>
     <th class="thHead" colspan="5">{L_SHOP_TITLE}</th>
   </tr>
   <tr>
<!-- BEGIN list_items -->
     <td class="{list_items.ROW_CLASS}" valign="top" align="center">
     <a href="{list_items.ITEM_URL}" title="{L_BUY} {list_items.ITEM_NAME}" class="nav"><b>{list_items.ITEM_NAME}</b><br />
     <img src="shop/bar/{list_items.ITEM_NAME}.gif" /></a><br />
     <span class="gensmall"><b>{L_INTOX_DUR}:<br />{list_items.ITEM_LENGTH}</b></span><br />
     <span class="gensmall"><b>{L_COST}: {list_items.ITEM_COST} lt.</b></span><br />
     <span class="gensmall"><b>{L_STOCK}: {list_items.ITEM_STOCK}</b></span>
     </td>
<!-- END list_items -->
   </tr>

<!-- BEGIN switch_no_drinks -->
   <tr>
     <td class="row3" colspan="4"><span class="gensmall"><b>{L_NO_DRINKS}</b></span></td>
   </tr>
<!-- END switch_no_drinks -->
<!-- BEGIN switch_is_drunk -->
   <tr>
     <td class="row3" colspan="4"><span class="gensmall"><b>{switch_is_drunk.L_TIME_LEFT}</b></span></td>
   </tr>
<!-- END switch_is_drunk -->
  </table>


I just move list.items switch after <tr> but now it's all displayed in one row.

Thanks.

p.s. i know maybe it's very simple, but i never did it before...
 

Zarath
Member

Sun Oct 15, 2006 10:54 pm   Post subject: re: Displaying items in shop
Need to add something like

if ( $i % 5 )
{
$template->assign_block_vars('break_line', array());
}

in the shop_bar.php file

then in the template file, after <!-- END list_items -->
add something like
<!-- BEGIN break_line -->
</tr>
<tr>
<!-- END break_line -->


That % 5 means every 5 items it will break line.
 

laisvai
Member

Mon Oct 16, 2006 4:59 am   Post subject:
I thought something about that, but this breaks wasn't very clear to me yesterday. I'll test it in the evening, but i think everything should work fine.
If this $i %5 means after every fith $i this if condition = true, then it's activates break line, and inserts new row. I didn't know this expression.

Thanks Smile i feel like i climbed another stair of php Smile
 

laisvai
Member

Mon Oct 16, 2006 12:05 pm   Post subject:
No way no step Laughing
it didn't work, i tried everything...seems i don't know something Confused
 

Page 1 of 3
Go to page 1, 2, 3  Next
Display posts from previous: