Jump to content

IPS Page. Custom Field printing html code than image


iJeff

Recommended Posts

I am using img src as the value in checkbox value field, as i want to display image than text ... and i am even using $vlaue|raw but still it would print html code than image... 

please see screenshot below how to get image instead ....505151360_ScreenShot2018-08-27at3_58_26PM.thumb.png.24cbb2cb2ae6b3106ea3145cbaeeedfe.png

 

 

Link to comment
Share on other sites

So the field type is checkbox? And what are the checkbox options exactly? 

You probably don’t want to make the options itself full HTML tags. Instead you just take the URL like  “iataMeta.png” or just “iataMeta” and then construct the rest outside the $value in the custom output field. All HTML posted there will actually render as HTML. 

Link to comment
Share on other sites

8 hours ago, opentype said:

So the field type is checkbox? And what are the checkbox options exactly? 

You probably don’t want to make the options itself full HTML tags. Instead you just take the URL like  “iataMeta.png” or just “iataMeta” and then construct the rest outside the $value in the custom output field. All HTML posted there will actually render as HTML. 

Yes correct it's checkbox.. I have tried URL alone with img src in 'custom' but it only works if there is one option otherwise it will render all selected options in img tag since $value contain all the 'selected' options if there are 2-3 options selected for a single option it solves the problem ... since it's comma separated ... i have tried foreach loop but it does not work ... I will post code here. 

If two options selected

<img src="https://fdir.co/stuff/meta/iataMeta.png, https://fdir.co/stuff/meta/iataMeta.png" height="20">

can there a for each loop for it ... so each selected option is rendered than get in src comma seperated?

Link to comment
Share on other sites

  • 4 months later...
1 hour ago, iJeff said:

@opentype btw, this code is not working. I hope you get it.. i am trying to display each option value in <li> I had taken it from your website.

 


{{$items=explode(',',$formValue);}}
<ul>
{{foreach $items as $item}}
<li>{{$item}}</li>
</ul>
{{endforeach}}

 

fixed with your method looping through each, i was expecting above code to work though 🙂

Screenshot 2019-01-23 at 3.18.39 PM.png

Link to comment
Share on other sites

45 minutes ago, Meddysong said:

I presume the problem with the above code is that you close the unordered list before the first loop. It should be closed after the looping has ended. 

Good catch! but that wasn't the problem, i even removed <ul> instead used <span> but to no avail, i had to loop each of them as in above article of opentype.

Link to comment
Share on other sites

When you want to output a variable, then you only need to surround it by single brackets. If you want to evaluate an expression (such as an if statement, foreach, endforeach, assigning a variable, etc.) then you need to use two brackets.

{{$items=explode(',',$formValue);}}
<ul>
{{foreach $items as $item}}
<li>{$item}</li>
{{endforeach}}
</ul>

 

Link to comment
Share on other sites

36 minutes ago, Ryan Ashbrook said:

When you want to output a variable, then you only need to surround it by single brackets. If you want to evaluate an expression (such as an if statement, foreach, endforeach, assigning a variable, etc.) then you need to use two brackets.


{{$items=explode(',',$formValue);}}
<ul>
{{foreach $items as $item}}
<li>{$item}</li>
{{endforeach}}
</ul>

 

Thanks worked. Also learned something new.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...