iJeff Posted August 27, 2018 Posted August 27, 2018 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 ....
opentype Posted August 27, 2018 Posted August 27, 2018 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.
iJeff Posted August 28, 2018 Author Posted August 28, 2018 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?
opentype Posted August 28, 2018 Posted August 28, 2018 Still not perfectly clear what you are doing, but have a look at this: https://www.opentype.space/superdocs/ips-community-tips/pages/multi-color-select-box-badges-with-pages-r16/ It explains how to deal with multiple values in the Pages custom display fields. For a different use, but the code might be helpful still.
iJeff Posted August 28, 2018 Author Posted August 28, 2018 @opentype Thanks, btw, I got to explore your work! i profoundly loved it ... Great Job!
iJeff Posted January 23, 2019 Author Posted January 23, 2019 @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}}
iJeff Posted January 23, 2019 Author Posted January 23, 2019 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 🙂
Meddysong Posted January 23, 2019 Posted January 23, 2019 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.
iJeff Posted January 23, 2019 Author Posted January 23, 2019 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.
Ryan Ashbrook Posted January 23, 2019 Posted January 23, 2019 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>
iJeff Posted January 23, 2019 Author Posted January 23, 2019 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.