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)
-   -   little help with a {if} statement (https://forum.x-cart.com/showthread.php?t=42660)

fotodog13 09-29-2008 08:34 AM

little help with a {if} statement
 
Hi All,
I am wondering if I am trying to add a {if} statement to my subcategory.tpl so that if a person lands on a certain subcategory page it displays a different page instead.

Specifically if a customer lands on $subcat.category id ="270" I want it to show page "264"

this is what I wrote which I thought might work

{if $subcat.categoryid="270"} $cat.categoryid="264"{/if}


I have tried to put it into the subcategory.tpl a variety of ways with no luck. This is the latest


<td class="ColumnTitles" valign="top"><a title="{$subcat.description}" <a href="home.php?cat={ $subcat.categoryid }
"><img src="{if $subcat.icon_url}{$subcat.icon_url}{else}{$xcart_w eb_dir}/default_image.gif{/if}" alt="" />
{if}{$subcat.categoryid="270"} $cat.categoryid="264"{/if}
<br/>
<span class="ItemsList">{ $subcat.category|escape }</span></a>
{if $config.Appearance.count_products eq "Y"}
{if $subcat.product_count}({ $subcat.product_count })
{elseif $subcat.subcategory_count}({ $subcat.subcategory_count })
{else} (0)
{/if}


Am I wrong in thinking that I should be able to make this idea work with a {if} statement?

If not can someone suggest what I need to do to get the page to redirect to the proper location.

As always thanks to all that take the time to answer, it's greatly appreciated.

Best

Scott V
aka fotodog13

xcart gold 4.1.11
apache

Jon 09-29-2008 09:15 AM

Re: little help with a {if} statement
 
If you elaborate on your reason for this I may be help you in providing a more elegant solution than if statements in your template.

fotodog13 09-29-2008 10:57 AM

Re: little help with a {if} statement
 
Hi Jon,

Sorry about the delay in reposting . Thanks for the response. This is what I am trying to do. the client I am doing this site for wants 4 of the categories to come up as listings on a subcategory page as well.

I did not see anyway to list the 4 categories ( they are in the root) in a subcategory as well- so I though that the best solution might be to add an {if) statement to the subcategories tpl for these.

If you go to
http://1090484.nwinetworks.com/home.php?cat=249

you will see 2 thumbnails that when click on lead to subcategory pages that say nothing is there. Rather than duplicating content I thought if I could just redirect these to corresponding category page

http://1090484.nwinetworks.com/home.php?cat=264
and
http://1090484.nwinetworks.com/home.php?cat=268


When the page is done it would look and work like this

http://1090484.nwinetworks.com/home.php?cat=250


If you have a better solution I'm all ears.

Thanks again

Scott V
fotodog13
4.1.11
apache

Jon 09-29-2008 11:43 AM

Re: little help with a {if} statement
 
I see, there isn't a real elegant solution to this unfortunately as x-cart won't allow a category to be both a root category and a subcategory.

In your .tpl find:

Code:

home.php?cat={ $subcat.categoryid }

Change to:

Code:

home.php?cat={if $subcat.categoryid eq '264'}270{else}{$subcat.categoryid}{/if}

In case the 264 subcategory is accessed from elsewhere you may want to put this code in your .htaccess:

Redirect 301 /home.php?cat=264 http://1090484.nwinetworks.com/home.php?cat=270

fotodog13 09-29-2008 03:46 PM

Re: little help with a {if} statement
 
Hey Jon,

Thanks for the help. You understand the problem I am having now.
Thanks for the code I put it in but can't seem to get it to work. I am wondering if won't because it is trying to pull a category from the subcategory.tpl and it won't allow for that in xcart.
It keeps going to the same pages as if the new code did not exist, but I can see it is in the subcategory.tpl

I had a feeling that this was going to happen and it was going to get ugly, trying to figure it out.

I am wondering if it would work better if I built a separate ( embeded) html page for just that subcategory landing page, and try to do something else to get the category pages to appear. I need to walk away from this for awhile.

Thanks again for the help if any other ideas come to mind how to make this work let me know. If I get it figured out I will give you a shout back.

FYI - Love your mods, hoping to get the client to open his wallet for them on this cart. I out them on the last site I built and they work great.

Best

Scott V
fotodog13
xcart 4.1.11
apache

fotodog13 09-30-2008 05:21 AM

Re: little help with a {if} statement
 
Hey Jon,

With a fresh set of eyes I was able to get what you gave me working but if I need to be able to do this more than once on the same subcategory page, and when I use the code you provided it only redirects to the category page on whatever is listed last in the code.

I have tried a bunch of variations on this, below is the last one.

Can you please take a look at it and tell me what you think.

here is what I have done

<td class="ColumnTitles" valign="top"><a title="{$subcat.description}" <a href="home.php?cat={if $subcat.categoryid eq '270'}264 {else}{$subcat.categoryid}
{/if}">
<a title="{$subcat.description}" <a href="home.php?cat={if $subcat.categoryid eq '254'}268 {else}{$subcat.categoryid}
{/if}">


<a title="{$subcat.description}" <a href="home.php?cat={if $subcat.categoryid eq '272'}267 {else}{$subcat.categoryid}
{/if}">


<a title="{$subcat.description}" <a href="home.php?cat={if $subcat.categoryid eq '271'}253 {else}{$subcat.categoryid}
{/if}">

<img src="{if $subcat.icon_url}{$subcat.icon_url}{else}{$xcart_w eb_dir}/default_image.gif{/if}" alt="" />

Basically this is what I want to happen

if a person lands on page id 270 it will pull up 264
if a person lands on page id 254 it will pull up 268
if a person lands on page id 272 it will pull up 267
if a person lands on page id 271 it will pull up 253

You can see the page here
http://1090484.nwinetworks.com/home.php?cat=249

As this page is written only Anniversary- (271 to 253) works. It is the last one in the line of code.

I think the idea is close and is probably something that can be done, but I am over my head

Many thanks in advance to you and anyway else that has the time to look

Best
Scott V
fotodog13
4.1.11 gold
apache





Jon 09-30-2008 07:39 AM

Re: little help with a {if} statement
 
Try:

Code:

<td class="ColumnTitles" valign="top">
<a href="home.php?cat={if $subcat.categoryid eq '270'}264{elseif $subcat.categoryid eq '254'}268{elseif $subcat.categoryid eq '272'}267{elseif $subcat.categoryid eq '271'}253{else}{$subcat.categoryid}{/if}">
<img src="{if $subcat.icon_url}{$subcat.icon_url}{else}{$xcart_w eb_dir}/default_image.gif{/if}" alt="" />


fotodog13 09-30-2008 08:02 AM

Re: little help with a {if} statement
 
Hey Jon,

This works like a charm !
Thanks again.

Thinking I will be over to your site CDSEO later today for some mods :)


Would I now do this to .htaccess file


Redirect 301 /home.php?cat=264 http://1090484.nwinetworks.com/home.php?cat=270

Redirect 301 /home.php?cat=268 http://1090484.nwinetworks.com/home.php?cat=254

Redirect 301 /home.php?cat=267 http://1090484.nwinetworks.com/home.php?cat=272

Redirect 301 /home.php?cat=253 http://1090484.nwinetworks.com/home.php?cat=271


Thanks again I really appreciate the help.

Jon 09-30-2008 08:06 AM

Re: little help with a {if} statement
 
No problem. I would remove the initial / but its not necessary:

Redirect 301 home.php?cat=264 http://1090484.nwinetworks.com/home.php?cat=270

Redirect 301 home.php?cat=268 http://1090484.nwinetworks.com/home.php?cat=254

Redirect 301 home.php?cat=267 http://1090484.nwinetworks.com/home.php?cat=272

Redirect 301 home.php?cat=253 http://1090484.nwinetworks.com/home.php?cat=271

fotodog13 09-30-2008 09:14 AM

Re: little help with a {if} statement
 
got it
thanks


All times are GMT -8. The time now is 04:02 PM.

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