Hi all,
So lets say I would like to give a user the possibility to choose an image for his weblink.
I would then create a TV called ’ImageDisplay’, and use the @DIRECTORY binding to load in all the images:
Ok, so far so good. Now I have a list of all the images and the option to choose one.
But... I would like to display the images in the directory as images instead of just file names:
How can I do that in a clever way? I guess I could go into the core and just put a wrapper <img> tag around the ’radio option’ code, but hacking the cores is bad I guess:
Here is the code from
manager/includes/tmplvars.inc.php line 123 and on:
case "option": // handles radio buttons
$index_list = ParseIntputOptions(ProcessTVCommand($field_elements, $field_name));
while (list($item, $itemvalue) = each ($index_list))
{
list($item,$itemvalue) = (is_array($itemvalue)) ? $itemvalue : explode("==",$itemvalue);
if (strlen($itemvalue)==0) $itemvalue = $item;
$field_html .= '<input type="radio" value="'.htmlspecialchars($itemvalue).'" name="tv'.$field_name.'" '.($itemvalue==$field_value ?'checked="checked"':'').' onchange="documentDirty=true;" />'.$item.'<br />';
}
break;
I guess perhaps I could even duplicate that whole block, and create my own ’view’. But then again, hacking the core is bad right?
I know that I could just use ’image’ instead of ’radio option’ as ’Input Type’ in my TV, but giving the user the cance to directly click on an image seems more appealing to me.
.larsb