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)
-   -   Only 2 extra fields in <a href> (https://forum.x-cart.com/showthread.php?t=50864)

BrighterBlooms1 11-20-2009 08:00 AM

Only 2 extra fields in <a href>
 
Need some help, i am trying to have one extra field be the anchor text with the other extra field fill in the URL, below is the code... tell me where i am going wrong.

Code:

{if $active_modules.Extra_Fields ne ""}

{include file="modules/Extra_Fields/product.tpl"}
       
       
  <tr>
            <td colspan="2" align="center" class="PlantBoxFooter">{section name=field loop=$extra_fields}
                {if $extra_fields[field].field_value and ($extra_fields[field].service_name eq "SERVICE_NAME15")}<a target="_blank" href="{$extra_fields[field].field_value}">{/if}{if $extra_fields[field].field_value and ($extra_fields[field].service_name eq "SERVICE_NAME13")} {$extra_fields[field].field_value} Planting Directions</a>{/if}{/section}
            </td>
        </tr>     
{/if}


ARW VISIONS 11-20-2009 09:21 AM

Re: Only 2 extra fields in <a href>
 
did you input any info into the extra field??

$extra_fields[field].field_value <--- thisis asking if the extra field has data

BrighterBlooms1 11-20-2009 09:40 AM

Re: Only 2 extra fields in <a href>
 
yes, there is info in the field... when i look at the source code of the output i get this...

Code:

<td colspan="2" class="PlantBoxFooter" align="center">
Knockout Rose Planting Directions<a target="_blank" href="/planting-directions/knockout-roses-care/"></a></td>



so it is picking up the values, just not putting them in the correct order. The anchor text is displayed outside the <a>

ARW VISIONS 11-20-2009 10:44 AM

Re: Only 2 extra fields in <a href>
 
maybe try this - move the {/if} inside teh </a> - just a guess

Planting Directions{/if}</a>

cflsystems 11-20-2009 11:32 AM

Re: Only 2 extra fields in <a href>
 
Your code is wrong
Code:

            {if $extra_fields[field].field_value and ($extra_fields[field].service_name eq "SERVICE_NAME15")}
    <a target="_blank" href="{$extra_fields[field].field_value}">
  {/if}
  {if $extra_fields[field].field_value and ($extra_fields[field].service_name eq "SERVICE_NAME13")}
    {$extra_fields[field].field_value} Planting Directions</a>
  {/if}

You will not get what you need like this because "field" and "service name" are the same for both ifs in each loop.
What do you have in first field and what in the second? Can you give example?

BrighterBlooms1 12-02-2009 09:45 AM

Re: Only 2 extra fields in <a href>
 
the first field "SERVICE_NAME15" is a URL, the second "SERVICE_NAME13" will be the anchor text for the link. such as

<a href="xxxxxxxx.com/xxx.html">TEST</a>

cflsystems 12-02-2009 10:45 AM

Re: Only 2 extra fields in <a href>
 
Try this
Code:

{if $active_modules.Extra_Fields ne ""}
 {include file="modules/Extra_Fields/product.tpl"}
 {section name=field loop=$extra_fields}
  {if $extra_fields[field].field_value and $extra_fields[field].service_name eq "SERVICE_NAME15"}
  {assign name="url" value=$extra_fields[field].field_value}
  {/if}
  {if $extra_fields[field].field_value and $extra_fields[field].service_name eq "SERVICE_NAME13"}
  {assign name="anchor" value=$extra_fields[field].field_value}
  {/if}
 {/section}
 {if $url and $anchor}
  <tr>
  <td colspan="2" align="center" class="PlantBoxFooter">
    <a href="{$url}">{$anchor}</a>
  </td>
  </tr>     
 {/if}
{/if}


BrighterBlooms1 12-02-2009 12:21 PM

Re: Only 2 extra fields in <a href>
 
i see what you are trying to do, yet the code is not displaying anything?

cflsystems 12-02-2009 02:32 PM

Re: Only 2 extra fields in <a href>
 
Where are you trying to execute this? Maybe $extra_fields is not available there. I can't really test this as I don't have 4.1.8. You can use the xcart debuger to see which variables are available on that page and what are they called

BrighterBlooms1 12-03-2009 12:35 PM

Re: Only 2 extra fields in <a href>
 
this is on product.tpl. which, as i understand, has extra fields available by default.


All times are GMT -8. The time now is 10:15 AM.

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