PDA

View Full Version : Custom field icons


sailfindragon
05-19-2009, 07:06 AM
Hi

Looking for some help

When a member submits an upload they are require to check boxes to state which additional items are required for that upload. This is fine, user just check the boxes.

However in the members upload it displays the additional items required in text format, i would like each individual check box to be assigned to an icon.

So if a user checks box 2 and 4, it shows the assigned icons instead of text. (showentry)

I am not sure what to do to achieve this.

Any help would be much appreciated

Brian
05-19-2009, 10:35 AM
You could add a new plugin to your 'vba_dyna_showentry_cfieldloop' hook location with code that looks something like this:

if ($field['fieldid'] == X)
{
$fvalue = explode(', ', $field['value']);
$field['value'] = '';

if (!empty($fvalue))
{
foreach ($fvalue AS $fieldvalue)
{
$field['value'] .= '<img src="images/customicon/' . $fieldvalue . '.gif" />';
}
}
}

Replace X on the first line there with the fieldid of the custom field you're trying to alter. Note you just need to add the number and the "field" part of the ID can be omitted. Then you will want to create a new folder at dynamics/images/customicon for your images and upload your new images there. Just make sure to name each image the exact same as the value for that choice in the custom field. For example, if your custom field has choices of "Apples", "Oranges", & "Pears", then you would create new images called "Apples.gif", "Oranges.gif" & "Pears.gif" and place them in the dynamics/images/customicon folder.

Our Sponsors
 

sailfindragon
05-19-2009, 11:56 AM
You could add a new plugin to your 'vba_dyna_showentry_cfieldloop' hook location with code that looks something like this:

if ($field['fieldid'] == X)
{
$fvalue = explode(', ', $field['value']);
$field['value'] = '';

if (!empty($fvalue))
{
foreach ($fvalue AS $fieldvalue)
{
$field['value'] .= '<img src="images/customicon/' . $fieldvalue . '.gif" />';
}
}
}

Replace X on the first line there with the fieldid of the custom field you're trying to alter. Note you just need to add the number and the "field" part of the ID can be omitted. Then you will want to create a new folder at dynamics/images/customicon for your images and upload your new images there. Just make sure to name each image the exact same as the value for that choice in the custom field. For example, if your custom field has choices of "Apples", "Oranges", & "Pears", then you would create new images called "Apples.gif", "Oranges.gif" & "Pears.gif" and place them in the dynamics/images/customicon folder.


Brian

I have added the above plugin using 'vba_dyna_showentry_cfieldloop', i have added the code and changed the X to 1 which corresponds to the field ID.
I have also added the icons to downloads/images/customicon and ensured that all the gifs contain the same name as the values.
However the icons are not showing at all. Where the text should be in showentry, there is nothing, just blank.

Have i missed something? This is the code i used in the plugin.

if ($field['fieldid'] == 1)
{
$fvalue = explode(', ', $field['value']);
$field['value'] = '';

if (!empty($fvalue))
{
foreach ($fvalue AS $fieldvalue)
{
$field['value'] .= '<img src="https://www.sailfinsims.com/downloads/images/customicon/' . $fieldvalue . '.gif" />';
}
}
}

Brian
05-19-2009, 04:28 PM
Off-hand I see the URL seems to be incorrect in your image. Try using just a relative URL instead.

$field['value'] .= '<img src="images/customicon/' . $fieldvalue . '.gif" />';

Our Sponsors
 

sailfindragon
05-19-2009, 04:58 PM
Brian

It's working perfectly.

Thank you so much