0

I am using this output from a radio array in a heredoc output

{$custom_radio2_2}

and wanted to add a font awseome icon to the variable output like <i class=fa fa-eye></i> - however if I just use it in the heredoc its always present...and I just want it to appear whenver that radio choice is made - (I have other icons for the other choices and they should also swap if a different choice is made.

The idea is not to have any icons showing if a choice is not made, but if one is, then the icon for that choice will show with the variable data

Am I making any sense, I tried adding different types of strings inside the brakets/braces? but all it does is dispaly onscreen (not good) how would I go about getting specific icons to show depending on the radio chosen?

2
Contributors
4
Replies
14
Views
5 Months
Discussion Span
Last Post by rproffitt
0

"The idea is not to have any icons showing if a choice is not made, but if one is, then the icon for that choice will show with the variable data"

I had such an app long ago and failed to achieve what you asked so I settled for a blank icon instead. Why this was, was due to the tools of the day and compiler, etc. Today, on a web page I might do differently but here, I thought I'd share how I worked around the no icon idea.

0

The only way I can get an icon to show, is to put it in the heredoc output - because if I try it in the array it breaks.

Probably becaue of the <> operators or the / that is associated with the string - could they be escaped in the array?

0

The array looks like this:

array(
            'type' => 'custom_radio',
            'heading' => __( 'First set of radios', 'rb_radio_tz' ),
            'param_name' => 'custom_radio3',
            'std' => '',
            // default unchecked - add radio name to set as checked
            'value' => array(
                __( 'Movie', 'rb_radio_tz' ) => 'Movie',
                __( 'DVD', 'rb_radio_tz' ) => 'DVD',
                __( 'Live Show', 'rb_radio_tz' ) => 'Live Show',
                __( 'Broadway', 'rb_radio_tz' ) => 'Broadway',
            ),
            'save_always' => true,
            'description' => 'Radio set one description',
              'group' => __( 'Radio Four', 'rb_radio_tz' )
        ),

If I try to add it like this: __( 'Live Show', 'rb_radio_tz' ) => '<i class=fa fa-eye></i> Live Show', it completely breaks the page... bummer

0

Escaped? I'm going with no. About all that I see in heredoc mode is the need to escape the dollar sign where appropriate.

So given PHP will sub in variables in the heredoc mode, I think I'm back to my idea where I could not with the system I was using have "no icon." I used a blank icon when needed.

So back to you to insert some variable into your code and heredoc. This change the variable to be the blank or other icon.

PS. Added with edit. Not to leave you without example.
http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
Notice how the substition works in example 7 and 10.

Edited by rproffitt: Clarifying

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.