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)
-   -   Product code (https://forum.x-cart.com/showthread.php?t=29291)

creative xpress 03-01-2007 11:19 AM

Product code
 
We are beginning to offer video content about some of our products and I am trying to create a link in the long decription that pops a new window and plays the video for that product.

My question is this: Is there any way to have the link carry the product code with it as a url variable without having to hard code the product code for each link?

For example
<a href=" somelocation.php?sku={$product.productcode}">

or would I be forced to do it this way
<a href="somelocation.php?sku=37-0001">

I am trying to make it so that I only have to add a very generic link to the description, that is the same for all products, and then have my script use the product code variable to select the video that needs to be shown. I have tried it a number of ways and the conclusion that I am coming to is that the link in the long description can not use the smarty or php variables.

What am I missing?

Thanks!
Cameron

balinor 03-01-2007 12:07 PM

Re: Product code
 
I don't think you can use smarty in the product description, at least not by default. You could put that link in product.tpl though, and it would automatically show up on every product.

creative xpress 03-01-2007 01:41 PM

Re: Product code
 
The problem is that I don't need it to show up on every product I only need it to show up on products that have a video. That is one of the reasons that I thought about doing it in the description.

I suppose I could add a field to the DB that is a simple yes or no field for having a video then add a call for that field and an if else statement to show the link.

Sounds simple enough but I am sure I will screw it up.

balinor 03-01-2007 01:53 PM

Re: Product code
 
You could also do it with Extra fields....let me know if you want more direction on that method.

creative xpress 03-01-2007 02:35 PM

Re: Product code
 
How would I go about it with extra fields? That sounds like less work. Don't get me wrong I am willing to do the work but extra fields would not affect my upgrades.

Thank you for your help!
Cameron

balinor 03-01-2007 02:53 PM

Re: Product code
 
Ok, two options:

1. You can put the actual html code in the extra field itself

2. You can use the extra field as a yes/no option. If yes, it displays the link on the product page, if no, it doesn't.

Which one do you think would work better for you?

creative xpress 03-02-2007 02:00 PM

Re: Product code
 
I am thinking that method two would work better for me. I don't want my people to have to remember to put the url in the field. I just want them to have a yes or no option and I will fill in the url in the template so that it doesn not change or get mis-typed.

balinor 03-02-2007 03:28 PM

Re: Product code
 
Ok, next question - do you use Extra Fields for anything else?

creative xpress 03-02-2007 04:39 PM

Re: Product code
 
Not currently. We might need to in the future but right now we do not use them.

balinor 03-03-2007 12:41 PM

Re: Product code
 
Ok, what I have done in the past is set up an extra field in the admin area. Call it 'Video' or something that makes it clear what it does. Then in customer/main/product.tpl, add this code where you want the link to the video to appear:

{if $extra_fields[0].field_value}
Code for pop-up
{/if}

That basically says that if the first extra field has a value, show the code. You can enter anything you want in the admin extra field area to get it to show up, but I typically just tell a client to type 'Y' in the box. If you don't want anything to appear for a product, just leave it empty.

Make sense?

carpeperdiem 03-03-2007 12:53 PM

Re: Product code
 
Wow, this is a GREAT idea. I see it useful for product videos, but also pop-up links, or other product specific details tha would be a royal PITA to insert on a per-product level in product details. By having a new field, you can do a numbering game by sku and SIMPLY have a product video (or not), using smarty to populate the video URL.

Very good idea. This post is now in my bookmarks for the future!

carpeperdiem 03-03-2007 01:00 PM

Re: Product code
 
PS -- does this mean we still have the 255 character limit for the aditional field? -- or if the field is yes/no, I guess this wouldn't matter... the code would be in product.tpl, trapping for the yes/no and then calculating the correct link. Yes?

additional field: does product have a video? Y if yes. Leave blank if no.

in product.tpl:
Code:

{if $extra_fields[0].field_value ne ""}
Code for pop-up - including productid from smarty to specify which link is called
{/if}


Padraic, you rock! Thanks.

creative xpress 03-05-2007 09:47 AM

Re: Product code
 
This worked out perfectly thank you for your help!!! I really appreciate it! One last question is the exra field available to the products_t.tpl so I can have a smaller icon appear on the thumbnail page?

Thanks!
Cameron

balinor 03-05-2007 10:05 AM

Re: Product code
 
Ahhh...that gets much more involved. Extra Fields won't work on the products templates by default. Look in the Wish List forum for a thread on getting Extra Fields to appear in other places than the product page....requires a bit of php and Smarty programming.


All times are GMT -8. The time now is 08:29 PM.

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