[Skip to main content](#vessel-content)

#   Extra field Link Option

##

- **[wrina iamwe](/forum/user/34481-wrina-iamwe "View wrina iamwe's Profile")**
- [![wrina iamwe's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34481-wrina-iamwe "View wrina iamwe's Profile") Topic Author
- [ Offline](/forum/user/34481-wrina-iamwe)

Less More

- Posts: 160
- Thank you received: 7
-
-

10 years 10 months ago [\#226619](#226619) by [wrina iamwe](/forum/user/34481-wrina-iamwe "View wrina iamwe's Profile")  *[Extra field Link Option](/forum/32-content-creation/881579-extra-field-link-option#226619 "-- HikaShop version -- : 2.6.1  I need to create a link to samples in the product display. I am using the extra fields' link plugin field - however the url link display is too long - is their a link field or a different field type that can be used to shorten the link url? I have tried an a href in the link field to generate a text display, but, that does not work.  Example: Display Field   thanks")* was created by *[wrina iamwe](/forum/user/34481-wrina-iamwe "View wrina iamwe's Profile")*

-- HikaShop version -- : 2.6.1

I need to create a link to samples in the product display.
I am using the extra fields' link plugin field - however the url link display is too long - is their a link field or a different field type that can be used to shorten the link url? I have tried an &lt;a href in the link field to generate a text display, but, that does not work.

Example:
&lt; a href="http:// ... "&gt;Display Field &lt; / a &gt;

thanks

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgxNTc5LWV4dHJhLWZpZWxkLWxpbmstb3B0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[Jerome](/forum/user/80-jerome "View Jerome's Profile")**
- [![Jerome's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar80.png)](/forum/user/80-jerome "View Jerome's Profile")
- [ Offline](/forum/user/80-jerome)
- HikaShop core developer

Less More

- Posts: 26402
- Thank you received: 4081
-
- [](http://obsi.dev)
-

10 years 10 months ago [\#226639](#226639) by [Jerome](/forum/user/80-jerome "View Jerome's Profile")  Replied by *[Jerome](/forum/user/80-jerome "View Jerome's Profile")* on topic *[Extra field Link Option](/forum/32-content-creation/881579-extra-field-link-option#226639 "-- HikaShop version -- : 2.6.1  I need to create a link to samples in the product display. I am using the extra fields' link plugin field - however the url link display is too long - is their a link field or a different field type that can be used to shorten the link url? I have tried an a href in the link field to generate a text display, but, that does not work.  Example: Display Field   thanks")*

Hi,

The idea would be to update the HikaShop link field (in the classes/field.php file).
With a code like Code:

$link = $value; $text = $value; if(preg_match('#"([^"]+)":(.*)#iU', $value, $m)) { $link = $m[2]; $text = $m[1]; } return '&lt;a'.$target.' href="'.$this-&gt;trans($link).'"&gt;'.$this-&gt;trans($text).'&lt;/a&gt;';

It would support special format for the links

> "Display field":http://website/link.html
> "Display field":/link.html

Regards,

---

Jerome - Obsidev.com
HikaMarket &amp; HikaSerial developer / HikaShop core dev team.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgxNTc5LWV4dHJhLWZpZWxkLWxpbmstb3B0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[wrina iamwe](/forum/user/34481-wrina-iamwe "View wrina iamwe's Profile")**
- [![wrina iamwe's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/34481-wrina-iamwe "View wrina iamwe's Profile") Topic Author
- [ Offline](/forum/user/34481-wrina-iamwe)

Less More

- Posts: 160
- Thank you received: 7
-
-

10 years 10 months ago [\#227015](#227015) by [wrina iamwe](/forum/user/34481-wrina-iamwe "View wrina iamwe's Profile")  Replied by *[wrina iamwe](/forum/user/34481-wrina-iamwe "View wrina iamwe's Profile")* on topic *[Extra field Link Option](/forum/32-content-creation/881579-extra-field-link-option#227015 "-- HikaShop version -- : 2.6.1  I need to create a link to samples in the product display. I am using the extra fields' link plugin field - however the url link display is too long - is their a link field or a different field type that can be used to shorten the link url? I have tried an a href in the link field to generate a text display, but, that does not work.  Example: Display Field   thanks")*

Hello Jerome, thanks for your help,

I have attempted to add the script you suggested.

I dont believe i have added to the correct class Code:

$fieldtype-&gt;load($field-&gt;field_table); if(!empty($fieldtype-&gt;externalOptions) &amp;&amp; isset($fieldtype-&gt;allValues[$field-&gt;field_type])) { $linkedOptions = $fieldtype-&gt;allValues[$field-&gt;field_type]['options']; foreach($fieldtype-&gt;externalOptions as $key =&gt; $extraOption) { if(in_array($key, $linkedOptions)) { $o = is_array($extraOption) ? $extraOption['obj'] : $extraOption-&gt;obj; if(is_string($o)) $o = new $o(); if(method_exists($o, 'save')) $o-&gt;save($fieldOptions); //wrina add // $link = $value; $text = $value; if(preg_match('#"([^"]+)":(.*)#iU', $value, $m)) { $link = $m[2]; $text = $m[1]; } return '&lt;a'.$target.' href="'.$this-&gt;trans($link).'"&gt;'.$this-&gt;trans($text).'&lt;/a&gt;'; //end add// } } }

Q. Where should the statement be placed? I dont believe the additional has affected the view, as it looks similar to the output that was rendered prior.
The script links to the external url, but the display text is doubled and displays a symbol. see image.

Thanks,
Wrina
Wrina
Thanks

- [ ![link&#95;error.png](/forum/attachment/28955) ](/forum/attachment/28955 "link&#95;error.png") [ ](/forum/attachment/28955?download=1 "link&#95;error.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgxNTc5LWV4dHJhLWZpZWxkLWxpbmstb3B0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14325
-
-

10 years 10 months ago [\#227046](#227046) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Extra field Link Option](/forum/32-content-creation/881579-extra-field-link-option#227046 "-- HikaShop version -- : 2.6.1  I need to create a link to samples in the product display. I am using the extra fields' link plugin field - however the url link display is too long - is their a link field or a different field type that can be used to shorten the link url? I have tried an a href in the link field to generate a text display, but, that does not work.  Example: Display Field   thanks")*

Hi,

I think that Jerome meant that you should improve the link type class: Code:

class hikashopLink extends hikashopText { function show(&amp;$field,$value) { $target = ''; if(isset($field-&gt;field_options['target_blank']) &amp;&amp; $field-&gt;field_options['target_blank'] == '1') $target = ' target="_blank"'; return '&lt;a'.$target.' href="'.$this-&gt;trans($value).'"&gt;'.$this-&gt;trans($value).'&lt;/a&gt;'; } }

So that it would be more adapted to your needs.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzMyLWNvbnRlbnQtY3JlYXRpb24vODgxNTc5LWV4dHJhLWZpZWxkLWxpbmstb3B0aW9uP3RtcGw9bWFya2Rvd24=) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.049 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
