Replace radion button selections with images
This topic contains 6 replies, has 2 voices, and was last updated by Emily Tarrant 7 years, 2 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
April 24, 2018 at 1:03 pm #427831
Hi folks
Could I ask for a little more help please?
On the site I’m building we’ve got tourism ratings depending on property type. So for example:
VisitBritain Guesthouses: 1 Star/2 Star/3 Star/4 Star/5 StarI’ve got this as a series of radio buttons, as follows:
NA/0,1 Star/1,2 Star/2,3 Star/3,4 Star/4,5 Star/5On the front end it is displaying as:
VisitBritain Guesthouses: No (if NA is selected)
or
VisitBritain Guesthouses: 4 Star (if 4 Star is selected)I’d like the ‘NA’s to not display at all and the star ratings to be replaced by the relevant image.
Can you give me some pointers please? From the markup I can’t see how I can target in on which radio button is selected.
Or is there a better way of achieving this?
Many thanks for your help!
EmilyApril 24, 2018 at 8:33 pm #427866Hi Emily,
Could you send over a link so we can see an example?
Also include site login information so we can take a look at the settings.Is this a custom field, and you are talking about the display of that field on the detail page?
We can see if we can find a CSS solution for it if you can show us where to look.
“WordPress Credentials
WP Admin Login URL:
WP Admin Username:
WP Admin Password:FTP is optional, but can be very helpful
FTP Credentials
FTP Host:
FTP Port:
FTP User:
FTP Password:Thanks!
April 28, 2018 at 7:49 am #428318Hi Alex
Sorry that I haven’t responded before. I forgot to tick the ‘notify me of follow-up replies’ box so hadn’t realised you’d replied. My fault!
I’m away from my office for a few days but I’ll get back to you with the info on Tuesday. Thanks for offering to take a look.
Cheers, Emily
April 28, 2018 at 10:11 am #428324OK, let us know.
May 1, 2018 at 12:16 pm #428609This reply has been marked as private.May 1, 2018 at 6:52 pm #428690Hello,
give this snippet a try:
// NOTE: change "geodir_Radio_Test" to your field name function _gd_custom_radio_output( $html, $location, $cf ) { global $post; if ( ! is_array( $cf ) && $cf != '' ) { $cf = geodir_get_field_infoby( 'htmlvar_name', $cf, $post->post_type ); } if ( empty( $cf ) ) { return NULL; } $html_var = $cf['htmlvar_name']; if ( ! empty( $post ) && in_array( $html_var, array_keys( (array) $post ) ) ) { $value = $post->{$html_var}; $image = ''; if ( $value == '1' ) { $image = 'http://mysite.com/images1.jpg'; } else if ( $value == '2' ) { $image = 'http://mysite.com/images2.jpg'; } $field_icon = geodir_field_icon_proccess( $cf ); if ( strpos( $field_icon, 'http' ) !== false ) { $field_icon_af = ''; } elseif ( $field_icon == '' ) { $field_icon_af = ''; } else { $field_icon_af = $field_icon; $field_icon = ''; } if ( $image != '' ) { $html = '<div class="geodir_more_info ' . $cf['css_class'] . ' ' . $cf['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-checkbox" style="' . $field_icon . '">' . $field_icon_af; $html .= (trim($cf['site_title'])) ? __($cf['site_title'], 'geodirectory') . ': ' : ''; $html .= '</span><img src="' . $image . '" style="width:16px;"></div>'; } else { $html = '<div style="display:none">'.$value.'</div>'; } } return $html; } add_filter( 'geodir_custom_field_output_radio_var_geodir_Radio_Test', '_gd_custom_radio_output', 10, 3 );
Let us know how it goes 🙂
The site is looking great, btw! Looking forward to seeing it in the showcase!
May 2, 2018 at 7:17 am #428751Hi Alex, you’re a star! That’s really helped me out.
The site is really coming together now I think. Still some features to add in, but hopefully not too far off being able to launch! Thanks for suggesting the showcase, I’ll submit it once it’s live.
Thanks again, Emily
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket