Linkable custom field

  • Posts: 10
  • Thank you received: 0
12 years 1 month ago #68643

I like to create a custom field for example "More info"
"More info" will listing on backend products information and I can key-in an external link address for example www.google.com
Visitor will be link to www.google.com when click "More info"
May I know how to do this ?

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 1 month ago #68809

Hi,

In your custom field, you can enter your link like that:
<a href=' www.google.com '>More info</a>

Please Log in or Create an account to join the conversation.

  • Posts: 15
  • Thank you received: 0
12 years 1 month ago #68827

Thank you, I's working.
How to do if I want to open NEW windows to display link page ?

Please Log in or Create an account to join the conversation.

  • Posts: 82818
  • Thank you received: 13361
  • MODERATOR
12 years 1 month ago #68833

Like that:
<a href=' www.google.com ' target='_blank'>More info</a>

The following user(s) said Thank You: shiva

Please Log in or Create an account to join the conversation.

  • Posts: 6
  • Thank you received: 1
12 years 3 hours ago #76950

Hi,
thanks, this topic was helpful.
However, I wonder if it would be possible to create this extra field in such way, that it won't be necessary to write HTML all the time, just to insert external URL when creating a product. I tried to play with field's default value, but it didn't work.

Please Log in or Create an account to join the conversation.

  • Posts: 26152
  • Thank you received: 4027
  • MODERATOR
12 years 1 hour ago #76994

Hi,

You can use view override to do such thing.
The view "shop_block_custom_main" display product custom fields for the product page.
The PHP code loop on all product custom field and display them.
You can modify the view and add some specific code in order to have specific display.

Like:

foreach ($this->fields as $fieldName => $oneExtraField) {
	$value = '';
	if(empty($this->element->$fieldName) && !empty($this->element->main->$fieldName))$this->element->$fieldName = $this->element->main->$fieldName;
	if(isset($this->element->$fieldName))
		$value = trim($this->element->$fieldName);
	if (!empty ($value)) {
		/* Begin of code to insert */
		if($fieldName == 'customlink') {
			echo '<tr class="hikashop_product_custom_'.$oneExtraField->field_namekey.'>_line"><td colspan="2"><a href="'.$value.'" target="_blank">More info</a></td></tr>';
			continue;
		}
		/* End of code to insert - Do not touch the rest */
		?>
And replace the "customlink" but the name of your custom field.

Regards,


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

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: idemsisvoje

Please Log in or Create an account to join the conversation.

  • Posts: 6
  • Thank you received: 1
11 years 11 months ago #77226

Super, i managed to make it work in less than 3 minutes. Thanks a lot!

Please Log in or Create an account to join the conversation.

Time to create page: 0.099 seconds
Powered by Kunena Forum