| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
extra fields, assigning a variable, using more than one extra field | ||||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() I am trying to do something that is just beyond my level of expertise. All help is appreciated.
MY ULTIMATE GOAL is to put a bunch of videos on specific product pages. To do this, I have encoded the videos into f4v format using Flash encoder CS4, and will use shadowbox and the JW player. It works great. Now, to get the videos onto the product.tpl -- I had a few ideas... A few pieces of info: I am using extra fields to propagate an INGREDIENTS tab (that is the only visible extra field -- I also have hidden extra fields too) -- I use a simple xyz.png for each products' ingredients, saved as an image. SO -- my questions/problems: 1. HOW can i constrain the extra fields to just a specific extra field in product.tpl? I thought I could use: {if $extra_fields[field].field eq "videocontent"} --- but that didn't work. IN my file, /skin1/modules/Extra_Fields/product.tpl It looks like this: Code:
This allows me to drop this template into the TABS for my ingredients, and the ingredients display, per product. I tried adding more code to /skin1/modules/Extra_Fields/product.tpl, but that just crashed the tabs. (yes, the tabs have an include for /skin1/modules/Extra_Fields/product.tpl ) HOW CAN I HAVE MORE THAN ONE EXTRA FIELD, and then if for the field name at different locations in product.tpl as well as other templates ? Additionally, to simplify the content in the extra field, and simplify the amount of code, can someone remind me of the technique to assign the results of an if string to a $variable, so that it can be used multiple times? This way, if my extra field, "videocontent" for product msp is simply "msp" -- then I can use the $msp string a few times, cutting down on code. Clear as mud? Thanks in advance for the assistance. Yes, I searched the forum, and even found answers from myself that I thought would be the solution, but it's not working... I must be losing brain cells. Thanks. Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#2
|
|||||||||
|
|||||||||
![]() Hi Jeremy -
I may not understand exactly what you are trying to do - but I do have a "sandbox" cart where I experiment. I dropped your code in several places in product.tpl and it worked as far as displaying the desired extra field. I don't have a tab mod, so that may be why I can't see the problem you are having. For your other question - was this what you need?: Code:
Then - you can use later: Code:
If it helps - you can PM me and I will give you access to my sandbox.
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold (CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module) |
|||||||||
#3
|
|||||||
|
|||||||
![]() Ah. var assign is exactly what I needed. Thanks. I had that code but late night brain cell drain prevented me from finding it.
As for the extra fields, my problem is having multiple extra fields, BUT only putting one on one place on the page, and a different one on another... the template will try to drop all of them at all instances... Maybe if I load up the template with all the variables, then use var assign code to place it, it will work.... I will try this right now. Thanks for pointing me in this direction. I will report back. Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#4
|
|||||||
|
|||||||
![]() Not working yet.
--- is the var assign good for the enitre template, and nested templates further down the page? For example: the file, modules/Extra_Fields/product.tpl looks like: Code:
then in product.tpl (toward the top), I include the template: Code:
so then, the var, {$ingred} should be propagated from here on within product.tpl, yes? Should I be able to use the var like this, somewhere lower on the product.tpl page: Code:
Unfortunately, it's not working. {$ingred) simply comes back blank. Nothing there. AM I MISSING SOMETHING in assigning the var? Thanks in advance for looking at this. Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#5
|
|||||||
|
|||||||
![]() PS -- if I include the var in the section loop, it appears... such as:
Code:
But this doesn't solve the issue of using $ingred in other locations on the page. Not to mention, trying to assign 2 different vars to be used in different places... ????
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#6
|
|||||||||
|
|||||||||
![]() I suspect you can't set the variable inside modules/Extra_Fields/product.tpl and it will be applied globally. If you can keep the setting of the variables inside product.tpl - you should be able to use the variables inside the nested templates. To have the variables available globally - I think you would have to set variables in the php files. But before doing that, maybe this will work for you:
At the top of skin1/customer/main/product.tpl - before you call any templates: Set all the variables: Code:
Then, you should be able to use the variables you set above later inside product.tpl and modules/Extra_Fields/product.tpl Code:
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold (CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module) |
|||||||||
#7
|
|||||||
|
|||||||
![]() This works. Thanks.
IT APPEARS that a variable is only good for the template it is created on, and nested templates. HOWEVER, you can't use an include to an outside template to make your variables. For example, this code in the top of product.tpl makes a bunch of variables, that can be used on product.tpl, and any other templates nested in it: Code:
However, if were to extract this code, call it extra_field_vars.tpl, and then do an include from product.tpl, it will not work. CAN SOMEONE VERIFY THIS IS CORRECT? Doesn't make sense, but this is what is happening. From there, I can go to town. This function allows me to upload about 25 videos via csv instead of manually editing 25 templates (and having to deal with a different template per product, when it's not needed). Thanks for sticking around to help me on this. I owe you one. Best, Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#8
|
|||||||||
|
|||||||||
![]() No problem - I tend to make use of the extra fields frequently - so I want to try and understand them as well.
I did try to set smarty variables in nested templates - and I can confirm that what you state is correct. I guess the compiler considers those variables local and does not pass them back to the calling template (surprisingly to me too). Your other option is to set the variables in the php - then they are available to you. (This is essentially the same as looping using the existing extra_fields array in the template - except this sets the variables in php). (This is thoroughly untested) : In modules/Extra_Fields/extra_fields.php Code:
Or - you could stick them in another array where the key is the field name: Code:
Then in the template: Code:
__________________
X-CART (4.1.9,12/4.2.2-3/4.3.1-2/4.4.1-5)-Gold (CDSEO, Altered-Cart On Sale, BCSE Preorder Backorder, QuickOrder, X-Payments, BCSE DPM Module) |
|||||||||
#9
|
|||||||
|
|||||||
![]() Thanks for the php code -- a question to php gurus: from a site optimization (speed) point of view -- is there much of a performance hit by using smarty (vs putting into the php) ? Is there a BETTER way to propagate extra fields into the templates? Is the core xcart code for extra fields the best way to do this?
I've learned on lot on this exercise, and my site is better for it. Thanks for the help. Jeremy
__________________
xcart 4.5.4 gold+ w/x-payments 1.0.6; xcart gold 4.4.4 |
|||||||
#10
|
|||||||
|
|||||||
![]() Here's a mod that saves you using the extra fields...
Uses Shadowbox with FLV player Up to 5 videos per product Set video width, height, description, URL and autoplay. http://www.xcartmods.co.uk/x-cart-shadowbox-v20-integration-v41x-x-cart-mods-pr-54.html
__________________
xcartmods.co.uk |
|||||||
|
|||
X-Cart forums © 2001-2020
|