Keyword

Extra fields show image instead of text

  • Daniel
  • Daniel's Avatar Topic Author
  • Offline
  • New Member
More
11 years 5 months ago #112254 by Daniel
I have an extra field selection called "hotel category" with the values ​​"1,2,3,4,5" and I want on the front end instead of showing the numbers show the image with the stars according to the selected number.

I know I can use something like: <
Log in  or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 5 months ago #112255 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Extra fields show image instead of text
Hello Daniel,

this will give you some hints getk2.org/community/New-to-K2-Ask-here-f...K2-after-Item-Fields

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Daniel
  • Daniel's Avatar Topic Author
  • Offline
  • New Member
More
11 years 5 months ago - 11 years 5 months ago #112256 by Daniel
Replied by Daniel on topic Re: Extra fields show image instead of text
Hi, thanks for your answer but the ink gives a 404 error, anyway I think you meant this:

getk2.org/community/New-to-K2-Ask-here-first/171284-Where- to-edit-K2-after-Item-Fields

But I still do not understand how to show an image according to the number you selected in the field. ?

Some more specific example?

Thanks in advanced.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 5 months ago #112257 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: Extra fields show image instead of text
You have to check which value is enabled and then show the appropriate image, the example is with one value but you can modify it easily.

It's all in the if else statement.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

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

  • Mohamed Abdelaziz
  • Mohamed Abdelaziz's Avatar
  • Offline
  • Platinum Member
  • Joomla Developer
More
11 years 5 months ago #112258 by Mohamed Abdelaziz
Replied by Mohamed Abdelaziz on topic Re: Extra fields show image instead of text
Say that the field alias is hotel_category, and its values are 1,2,3,4 and 5
And your images names are 1.png, 2.png, 3.png, 4.png and 5.png
and the images relative path is: images/hotelcategory/

in the item.php file, you will insert the following html code in the required position:
<img src="images/hotelcategory/<?php echo $this->item->extraFields->hotel_category->value;?>.png" />

Make sure to add it as html code.

It is planned to add this feature to my MEFG plugin, where it will be possible to map select/mutliselect/checkbox/radiobutton field values to images.

Multiple Extra Fields Groups for K2
AutoMeta for K2
Chained Fields for K2
More K2 Extensions In My Extensions Store

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