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)
-   -   Getting Feautured Products to display in all categories (https://forum.x-cart.com/showthread.php?t=43285)

bionuts 10-28-2008 04:21 AM

Getting Feautured Products to display in all categories
 
I want to make use of the Featured Products functionality and have a selection of products featured in each category, not just on the home page, but it seems that as soon as I put products into a category, this stops the Featured Products from displaying.

This seems, to me, a strange way for X Cart to behave - why can I only have Featured Products in a category when there are no products in that category? Surely you only want to have Featured Products when the category actually has some products in it?

I've done a search of the forums and have seen that there are quite a few people asking this same question but of the suggestions that I've seen for fixes, none of the ones I've tried have worked. Is there a (simple enough for a non-coder to undestand) way to get X Cart to display Featured Products even in categories that already contain products?

I'm using version 4.1.9 of X Cart.

Verfurt 10-28-2008 04:52 AM

Re: Getting Feautured Products to display in all categories
 
In the skin1/customer/main/subcategories.tpl find the code:

Code:

{if $products eq ""}
{if $f_products ne ""}
<p />
{include file="customer/main/featured.tpl"}
{/if}
{/if}


And replace it with:

Code:

{if $f_products ne ""}
<p />
{include file="customer/main/featured.tpl"}
{/if}


Didn't test it, but it used to work ;)

JWait 10-28-2008 05:14 AM

Re: Getting Feautured Products to display in all categories
 
Quote:

Originally Posted by bionuts
Is there a (simple enough for a non-coder to undestand) way to get X Cart to display Featured Products even in categories that already contain products?

I'm using version 4.1.9 of X Cart.


The short answer is no. Maybe it doesn't make sense to you but it is a either/or situation. Since you can (in theory) have unlimited featured products, and also (in theory) have unlimited products within the category, it becomes a matter of which is most important.

The featured products will be displayed if all of the products listed in the main category are out of stock (provided the don't display products that are out of stock option is checked in admin). Otherwise, the regular products will be displayed

Here are two ways around the situation...
1 You can list the products that you would normally list in the main category in a sub-category instead, and make them featured products of the main category.
2. You can display featured products on the main home page only.

bionuts 10-28-2008 05:55 AM

Re: Getting Feautured Products to display in all categories
 
@verfurt
Thanks for that, but it didn't work for me.

bionuts 10-28-2008 06:11 AM

Re: Getting Feautured Products to display in all categories
 
Quote:

Originally Posted by JWait
1 You can list the products that you would normally list in the main category in a sub-category instead, and make them featured products of the main category.

Not an ideal solution, in that I don't need to use sub-categories, so don't want to go creating them just so that I can have Featured Products displayed.
Quote:

Originally Posted by JWait
2. You can display featured products on the main home page only.

Which is what I am currently doing, and it works fine for the home page; it would just be nice if it worked for the category pages too.

To me, Featured Products are ones that you want to highlight from within the category. So, if a category has 10 products, you might want to highlight product1 and product3 which have been reciving attention in the media lately. You'd still want them in the list of products in the category as well (not moved to a sub-category), you just want to draw a bit more attention to them. This is why I don't think that Featured Products should be an either / or situation.

Ene 10-28-2008 06:11 AM

Re: Getting Feautured Products to display in all categories
 
You also need to modify the home.php script.

Replace this code

PHP Code:

if (empty($products))
    include 
"./featured_products.php"


with this one:

PHP Code:

include "./featured_products.php"


bionuts 10-28-2008 06:23 AM

Re: Getting Feautured Products to display in all categories
 
@Ene
I did that, in conjunction with the change highlighted by Verfurt, but that makes only the Featured Products display - I don't get the rest of the products from the category.

bionuts 10-28-2008 10:34 AM

Re: Getting Feautured Products to display in all categories
 
Ok, more reveals slightly more success.

When making Ene's change, it doesn't seem to work unless you place his line of code ahead of this code:
Code:

if (!empty($cat))
        include "./products.php";

It would normally come after this code and, left in that position, the change doesn't seem to have any effect.

Then, if you also make Verfurt's change the featured product box does appear on the category page. Further, moving the code up the file moves the featured product box position on the web page. That's all good and a step forward.

The problem is that by making the change that Ene suggests and moving it as I've indicated, for any categories that have more than one page the navigation bar is no longer displayed. So, if we can just solve that issue then all will be hunky dory.

bionuts 10-28-2008 11:18 AM

Re: Getting Feautured Products to display in all categories
 
In another thread on the subject (http://forum.x-cart.com/showthread.php?t=40988&highlight=featured+products ) Tbone makes some further changes that (combined with the ones above) do restore the navigation to categories that have more than one page:

Quote:

Originally Posted by TBone
In featured_products.php

add
$searchtype="featured";
just before
include $xcart_dir."/include/search.php";

and comment out
$smarty->clear_assign("products");

In include/search.php

replace
$smarty->assign("products", $products);
with
if (!$searchtype=="featured") {
$smarty->assign("products", $products);
}

In products.php

add
$products = array();
unset($search_data, $products);
Just before
?> at the bottom of the page

These changes mean that the Featured Products box is displayed on the category page, and the navigation for categories with more than one page is maintained. All of this is good and another step forward.

Unfortunately, the navigation is repeated in the Featured Product box and this is wrong. There shouldn't be any navigation in there at all. Anyone know how to stop that?

bionuts 10-28-2008 11:31 AM

Re: Getting Feautured Products to display in all categories
 
And the solution to that is to edit featured.tpl in skin1/customer/main and take out the references to customer/main/navigation.tpl.

So there we go; problem solved. Featured Products that display on every category page that has featured products set (the box does not display if there are no products set in the admin panel). Just what I was looking for, but rather more difficult than it needed to be to achieve, I feel.


All times are GMT -8. The time now is 09:48 AM.

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