Can I make a custom field a hyperlink

  • Posts: 63
  • Thank you received: 3
11 years 6 months ago #98775

Hi there,

I've made a custom field called IMDb which I'd like to link to a website in the product details page.

It's all OK, except it doesn't recognise its a hyperlink. typical entry is - www.imdb.com/Title?0037536

Is there a way of making this a hyperlink?

Another solution could be to use the core URL field which does recognose hyperlinks. How would I re-name the field to read IMDb?

Help apprecated :-)

Ian

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

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 6 months ago #98924

Hi,

Next version of HikaShop will have a type "link" for custom fields.
For now, you would have to edit the file "show_block_custom_main" of the view "product" via the menu Display->Views and change the line:

<?php echo $this->fieldsClass->show($oneExtraField,$value); ?>

to:
<?php if($fieldName=='imdb'){echo '<a href="'.$value.'">'.$value.'</a>';}else{ echo $this->fieldsClass->show($oneExtraField,$value);} ?>

The following user(s) said Thank You: ians

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

  • Posts: 63
  • Thank you received: 3
11 years 6 months ago #99714

Thank you Nicolas - worked a treat :-)

Ian

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

  • Posts: 63
  • Thank you received: 3
11 years 5 months ago #104127

Thanks again for the modifoed code.

My customer would like the link to open in a new window. Is this possible?

Yours,

Ian

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

  • Posts: 82760
  • Thank you received: 13346
  • MODERATOR
11 years 5 months ago #104129

Instead of <a href="'.$value.'"> in my code, use: <a href="'.$value.'" target="_blank">

The following user(s) said Thank You: ians

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

  • Posts: 63
  • Thank you received: 3
11 years 5 months ago #104132

Brilliant - Thank you Nicolas :-)

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

Time to create page: 0.060 seconds
Powered by Kunena Forum