X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Adding Product Listing to Detailed Product Page (https://forum.x-cart.com/showthread.php?t=38542)

RobinThor 03-23-2008 07:56 PM

Adding Product Listing to Detailed Product Page
 
Hi I'm a new user to X-Cart, but I'll like to know how is it possible to have a product listing of the category at a detailed product page?

This is something like what I'm referring to : http://www.ahavaus.com/site/body_handcream.html

I'm not sure if I'm doing this right, but I think this would mean that I have to edit home.tpl to include the codes from products_t.tpl right? But I'm having a problem because home.tpl will know recognise the $product array variable from products.tpl or product_t.tpl.

Any help on this would be greatly appreciated!! Thanks a lot for your time!!

balinor 03-24-2008 03:21 AM

Re: Adding Product Listing to Detailed Product Page
 
So you want to show all the products in a category at the product detail level?

Yurij 03-24-2008 04:15 AM

Re: Adding Product Listing to Detailed Product Page
 
1 Attachment(s)
Quote:

Originally Posted by RobinThor
Hi I'm a new user to X-Cart, but I'll like to know how is it possible to have a product listing of the category at a detailed product page?

This is something like what I'm referring to : http://www.ahavaus.com/site/body_handcream.html

I'm not sure if I'm doing this right, but I think this would mean that I have to edit home.tpl to include the codes from products_t.tpl right? But I'm having a problem because home.tpl will know recognise the $product array variable from products.tpl or product_t.tpl.

Any help on this would be greatly appreciated!! Thanks a lot for your time!!


For version 4.1.9, I would have done so:

In the file "product.php" insert the following lines (before - "# Assign the current location line"):
PHP Code:

$allproduct = array();
$allproduct func_query ("SELECT * FROM $sql_tbl[products]$sql_tbl[products_categories] WHERE $sql_tbl[products].productid=$sql_tbl[products_categories].productid AND $sql_tbl[products].forsale='Y' $avail AND $sql_tbl[products_categories].categoryid='$cat'");
$smarty->assign("allproduct"$allproduct); 



In the end file "skin1\customer\main\product.tpl" insert the following lines:
PHP Code:

<br>
{
capture name=dialog}
{
assign var="count_per_row" value=3}
<
table border=0 width=100%>
{
math equation="floor(100/x)" x=$count_per_row assign="width"}
{
section loop=$allproduct name=ind}

{if %
ind.indexis div by $count_per_row}
<
tr>
    {
assign var="cell_counter" value=0}
{/if}
    {
math equation="x+1" x=$cell_counter assign="cell_counter" }

<
td valign=top  align=center width={$width}%>
<
table border=0>
    <
tr>
        <
td align=center>

            {include 
file="product_thumbnail.tpl" productid=$allproduct[ind].productid image_x=$allproduct[ind].tmbn_x|default:$config.Appearance.thumbnail_width image_y=$allproduct[ind].tmbn_y product=$allproduct[ind].product tmbn_url=$allproduct[ind].tmbn_url}
        </
td>
    </
tr>
    <
tr>
        <
td>
            <
a href="product.php?productid={$allproduct[ind].productid}&amp;cat={$cat}class="ProductTitle">{$allproduct[ind].product}</a>
        </
td>
    </
tr>
</
table>

</
td>

{
capture name=prod_index}
    {
math equation="index+x+1" index=%ind.indexx=$count_per_row}
{/
capture}


{if 
$smarty.capture.prod_index is div by $count_per_row}
    </
tr>
{/if}
{/
section}

    {if 
$cell_counter lt $count_per_row}
    {
section name=rest_cells loop=$count_per_row start=$cell_counter}
        <
td class="SectionBox">&nbsp;</td>
    {/
section}
    {/if}
</
tr>
</
table>


{/
capture}
{include 
file="dialog.tpl" title="All products" content=$smarty.capture.dialog extra='width="100%"'


Result:

Attachment 852

{assign var="count_per_row" value=3} - Specifies the number of products displayed in a row.

RobinThor 03-24-2008 08:43 AM

Re: Adding Product Listing to Detailed Product Page
 
Hi Yurij,

Thanks a lot! It works! One more question: Supposing you want to have multiple pages on the product listing? What additional code will you need to add?

Yurij 03-25-2008 12:12 AM

Re: Adding Product Listing to Detailed Product Page
 
At a detailed product page? Or where?

RobinThor 03-25-2008 06:45 PM

Re: Adding Product Listing to Detailed Product Page
 
Hi Yurij,

For the multiple pages for the products listing. I actually amended a bit of your code, so now the product listings will be reflected on the right column. But what if there are too many products in the category and I'll like to have a page selector?

Yurij 03-26-2008 12:36 AM

Re: Adding Product Listing to Detailed Product Page
 
I see no sense in that.
In this unit output products for selected product categories.
The same, we will see if we select the product category (with page navigation).

Maybe it makes sense to withdraw the first 5-10 products, and then to link at the bottom (View all product), which will rely on the product category.

ben@lrb.co.uk 04-01-2008 07:51 AM

Re: Adding Product Listing to Detailed Product Page
 
Yurij,

I'm really interested in doing something similar to this, but to display all products in a specific category in a little table on the homepage, rather than in every product template.

Do you think this could be done by adapting your code, and if so what would I need to alter?

Many thanks,

Rachael

Yurij 04-02-2008 12:09 AM

Re: Adding Product Listing to Detailed Product Page
 
Look at this:

http://forum.x-cart.com/showthread.php?t=38250


All times are GMT -8. The time now is 08:46 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.