X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Extra Fields 4.1.x products_t.tpl (https://forum.x-cart.com/showthread.php?t=25143)

ChristineP 02-24-2009 06:35 AM

Re: Extra Fields 4.1.x products_t.tpl
 
Hi toltion,

How does this work for multiple extra fields on the product.tpl page?


Quote:

Originally Posted by toltion
Hi Christine,

You need to LOOP through the Extra fields and display the one using an {if} statement -

Code:

        {section name=field loop=$extra_fields}
        {if $extra_fields[6].value ne ""}
        {$extra_fields[6].value}
        {/if}
        {/section}



toltion 02-24-2009 07:06 AM

Re: Extra Fields 4.1.x products_t.tpl
 
The code allows you to selectively display any extra field. I sometimes like to display the extra fields in different locations on the template, so I run the code at the top of the page and assign variables to the values. In this code I chose to identify the extra_fields by their Service Name instead of index position in the loop -
Code:

{section name=field loop=$extra_fields}
{if $extra_fields[field].service_name eq "NO_SHIP_AIR"}
    {if $extra_fields[field].field_value ne ""}{assign var="no_ship_air" value="Y"}{/if}
{/if}
{if $extra_fields[field].service_name eq "CLEARANCE_PRICE"}
    {if $extra_fields[field].field_value ne ""}{assign var="clearance_price" value="Y"}{/if}
{/if}
{/section}


Then I can display the variables "no_ship_air" & "clearance_price" anywhere on the page using {if $no_ship_air ne ""}{$no_ship_air}{/if}.

ChristineP 02-24-2009 08:54 AM

Re: Extra Fields 4.1.x products_t.tpl
 
With your suggested code, I believe I have the "loop through" working in /modules/Extra_Fields/product.tpl, though I haven't been able to place each of my extra fields separately in customer/main/product.tpl.

This is what I have for my product.tpl
{if $active_modules.Extra_Fields ne ""}
{include file="modules/Extra_Fields/product.tpl"}

When I tried adding just one field name, there was no change
{if $active_modules.Extra_Fields ne ""}{$product.extra_fields.11.value}
{include file="modules/Extra_Fields/product.tpl"}

Can you see what I'm missing to call out individual extra fields where I need in my customer/main/product.tpl?

Christine

Quote:

Originally Posted by toltion
The code allows you to selectively display any extra field. I sometimes like to display the extra fields in different locations on the template, so I run the code at the top of the page and assign variables to the values. In this code I chose to identify the extra_fields by their Service Name instead of index position in the loop -
Code:

{section name=field loop=$extra_fields}
{if $extra_fields[field].service_name eq "NO_SHIP_AIR"}
    {if $extra_fields[field].field_value ne ""}{assign var="no_ship_air" value="Y"}{/if}
{/if}
{if $extra_fields[field].service_name eq "CLEARANCE_PRICE"}
    {if $extra_fields[field].field_value ne ""}{assign var="clearance_price" value="Y"}{/if}
{/if}
{/section}


Then I can display the variables "no_ship_air" & "clearance_price" anywhere on the page using {if $no_ship_air ne ""}{$no_ship_air}{/if}.


toltion 02-24-2009 10:20 AM

Re: Extra Fields 4.1.x products_t.tpl
 
In customer/main/product.tpl, you have to replace -

{include file="modules/Extra_Fields/product.tpl"}

With the code I suggested.

You are basically looping through the extra fields directly on product.tpl instead of including "modules/Extra_Fields/product.tpl".

ChristineP 02-24-2009 11:12 AM

Re: Extra Fields 4.1.x products_t.tpl
 
Awesome! I have one more piece to this that I need working. I have a custom button that I'm trying to get working for 3 of my extra fields. Here's what I've done with trying to add my custom button .tpl:

In customer/main/product.tpl I commented out
<!--{if $active_modules.Extra_Fields ne ""}
{include file="modules/Extra_Fields/product.tpl"}
{/if}-->

and added from your code suggestion
<table align="left" cellspacing="0" cellpadding="0">
{section name=field loop=$extra_fields}
<td>{if $extra_fields[field].service_name eq "products_PDF"}
{include file="buttons/pdf_button.tpl" href="javascript:window.open $extra_fields[field].field_value=products_PDF" style="button"}
{/if}</td>
<td>&nbsp;&nbsp;</td>
<td>{if $extra_fields[field].service_name eq "products_manual"}
{$extra_fields[field].field_value eq "products_manual"}
{/if}</td>
<td>&nbsp;&nbsp;</td>
<td>{if $extra_fields[field].service_name eq "product_image"}
{$extra_fields[field].field_value eq "product_image"}
{/if}</td>
{/section}
</table>

The bold is my attempt for my custom button. The image of my custom button is now showing, though it's not clickable to my product.

Do you have any suggestions?

Christine

Quote:

Originally Posted by toltion
In customer/main/product.tpl, you have to replace -

{include file="modules/Extra_Fields/product.tpl"}

With the code I suggested.

You are basically looping through the extra fields directly on product.tpl instead of including "modules/Extra_Fields/product.tpl".


toltion 02-24-2009 12:49 PM

Re: Extra Fields 4.1.x products_t.tpl
 
Try this...

<table align="left" cellspacing="0" cellpadding="0">
{section name=field loop=$extra_fields}
<td>{if $extra_fields[field].service_name eq "products_PDF"}
{include file="buttons/pdf_button.tpl" href="javascript:window.open $extra_fields[field].field_value" style="button"}
{/if}</td>
<td>&nbsp;&nbsp;</td>
<td>{if $extra_fields[field].service_name eq "products_manual"}
{$extra_fields[field].field_value}
{/if}</td>
<td>&nbsp;&nbsp;</td>
<td>{if $extra_fields[field].service_name eq "product_image"}
{$extra_fields[field].field_value}
{/if}</td>
{/section}
</table>

Not too sure about your javascript window.open code. Doesn't look like that will work...

ChristineP 02-24-2009 01:09 PM

Re: Extra Fields 4.1.x products_t.tpl
 
Great job. Thanks for your help! I have the loop through working.

For my custom button, I will need to get mod work done.

Christine

chastie 03-29-2009 03:34 PM

Re: Extra Fields 4.1.x products_t.tpl
 
Thank you thank you!

Hallsons 05-30-2009 06:50 PM

Re: Extra Fields 4.1.x products_t.tpl
 
Hi,

I can't find where to insert the code in 4.1.11 as I can't find the $smarty->assign line mentioned.

Where should I insert this to call up the extra fields?

Thanks,

Chris

gb2world 05-30-2009 09:08 PM

Re: Extra Fields 4.1.x products_t.tpl
 
Are you modifying products.php? It should be near the last lines of the file. The php code goes in the products.php file, the smarty and html changes go in the template files.


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

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