Announcement

Collapse
No announcement yet.

Adding an optional image to each Radio Button Choice.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Adding an optional image to each Radio Button Choice.

    Someone was asking if Actinic allowed images on Choices. The answer was that it isn't built-in. However it's now really easy in V8 to extend Actinic to do just that.

    Adding an optional image to each Radio Button Choice.


    In Design / Library / Variables, right click Library and select New Variable.

    Make the following settings:

    Code:
    Name			ChoiceImage
    Description		An image to use with this choice.
    Prompt	 		Image
    Group			Choice
    Place of Setting	Choice
    Allow <Use Parent>...	Unchecked
    Tab Name		General
    Type			Filename
    Allow Empty Value	Checked
    Initial Value		<blank>
    Top Level Value		<blank>
    OK out.


    Go to Design / Library / Layouts / Choices
    Double-click Radio Button Choice and replace all the code with the following


    Code:
    <input type="radio" name="<Actinic:Variable Name="UIWidgetName"/>" value="<Actinic:Variable Name="ChoiceSelectedValue"/>"<actinic:block if="%3cactinic%3avariable%20name%3d%22ListIndex%22%20%2f%3e%20%3d%3d%201">checked="checked"</actinic:block> />
    <Actinic:Variable Name="ChoiceDisplayLabel"/><actinic:block php="true">
    	$choiceimage = '<Actinic:Variable Name="ChoiceImage" encoding="perl" selectable="false" />';
    	if ( $choiceimage )
    		{
    		list($width, $height, $type, $attr) = getimagesize($choiceimage);
    		if ( $width )
    			{
    			echo " <img src=\"$choiceimage\" width=\"$width\" height=\"$height\" />";
    			}
    		else
    			{
    			echo "<font color=\"red\"><b> BAD IMAGE</b></font>";
    			}
    		}
    </actinic:block>&nbsp;&nbsp;
    OK out and that's it.

    Your Choice Details dialogue should now have a new entry Choices / Image, where you can browse for an image to add to this choice.
    Last edited by NormanRouxel; 09-Oct-2006, 10:02 AM. Reason: Added automatic generation of width and height parameters.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    #2
    Wonderful stuff!

    I've been wanting to find time to do something like this for ages. The other one I am working on is specifying an image for each choice and then changing the product image based on the choice selected.

    Comment


      #3
      Norman - are you happy for me to add this to the Advanced User Guide?

      Comment


        #4
        are you happy for me to add this to the Advanced User Guide?
        Yes. That's why I posted it here. It was also posted to help another thread who wanted a text variable set per choice.
        The other one I am working on is specifying an image for each choice and then changing the product image based on the choice selected.
        The code I posted above is a subset of my V8-Dynamic Product Images patch that does just that. It was a solid days work to get that working so I won't be posting it here but it will be available as a £25 add-on.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Is this ever liekly to be an option for V7?

          thanks

          Comment


            #6
            I have a similar patch for V7.

            It's less sophisticated than the V8 one (e.g. you have to provide alternate images that are the same size as your main product one).

            It's not free so you'd have to contact me by email for info.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment

            Working...
            X