Announcement

Collapse
No announcement yet.

Using choice to show image

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

    #16
    Inexplicable bug. There' nothing wrong with my code yet something is executing it twice. Try this

    Look for the line:
    Code:
    			$swatchname = $htmlforname . '.jpg';
    After it add:
    Code:
    			echo " $swatchname <actinic:variable name="ListIndex" /> ";
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #17
      I've uploaded the new page but by the look of it, I think your code is not at fault.
      I set up a new site and pasted the code directly from the main site into it and all was well. It just shows the colours once. I've switched back to the original site and it's still showing twice.

      Could it be effected by some other PHP?
      Clothing to make an impression.
      www.stitchfactory.co.uk

      Comment


        #18
        Is the other site using an identical version of Actinic?

        Is so, then are you sure that you've not got my lump of code in your layout twice (and are only tweaking one copy)? That's the only thing I can think is happening.

        Also, are you sure that you want to use file-names with spaces in them? It would be better to convert spaces in the colour names to underscores (and make everything lower-case) so Mid Blue would use file-name mid_blue.jpg.

        To do that change the line:
        Code:
        $swatchname = $htmlforname . '.jpg';
        To be:
        Code:
        $swatchname = strtolower(str_replace(' ', '_', $htmlforname)) . '.jpg';
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #19
          sorry for the delay.

          I finally managed to make the time to open a back-up from before 27/06/10 and paste the code just once into the product layout and I get the same result, a doubling of the images.

          Is it possible that a custom variable is being used more than once?
          Clothing to make an impression.
          www.stitchfactory.co.uk

          Comment


            #20
            Hmmmm... this isn't working when we try and introduce this code. When published the live page shows no signs of the code despite an image with the same name as one of the choices being present in Site 1.

            Would the image need to be referenced as an Additional File?
            Is this code compatible in V9?
            Would it matter if there is both a size and colour option?
            Webfaced - Award-Winning SellerDeck Web Design Agency

            Comment


              #21
              Should work on Preview. If nothing shows there put some diagnostic text into amended layout. If that doesn't show, you may be altering the wrong Choice List. E.g. Different ones are used for Permutation Choices.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #22
                Hmmm... I added the diag code you entered earlier in the thread but still none of this appearing in either Preview or on the published page.

                I have added the code as you posted it into the Extended Info page for a product that has a size and colour option.



                ...and here are the choices...



                ...so maybe the PHP is using the wrong choice/option?
                Webfaced - Award-Winning SellerDeck Web Design Agency

                Comment


                  #23
                  Norman, should I be doing anything else? As I understand the code this will use the name of each choice to search through the Site folder and look for a file that is called the same (with .jpg) added on.

                  I have only added one image (Red.jpg) to the Site folder but this isn't showing up. I tested the PHP was executing by hardcoding a value for $swatchhtml in the first line and this was then printed into the page. Not sure if this helps?
                  Webfaced - Award-Winning SellerDeck Web Design Agency

                  Comment


                    #24
                    Two things to try:

                    1) Use variable ChoiceName instead of ChoiceDisplayLabel. The ChoiceDisplayLabel is the HTML for Name field and this may be different from the choice name.

                    2) Debug by changing

                    if ( file_exists($swatchname) )

                    to be

                    if ( 1 )

                    and this will force IMG tags to be displayed for all Choices. Look at the generated HTML and report what you see.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #25
                      Really odd... Tried both suggestions and yet still I see no trace of the code or it's effects. This is barmey... If I force $swatchhtml to be 'anythingitype' then the PHP is echoing this correctly. Odd!
                      Webfaced - Award-Winning SellerDeck Web Design Agency

                      Comment


                        #26
                        I think I see it. As I surmised in post #21, you are altering the wrong Choice List. Your 2nd screenshot in post #22 shows that these are Components with Attribute Choices, not simple Attribute List Choices.

                        Much more difficult to do and not the purpose of my original bit of code. It was intended for simple Attributes / Choices.

                        Try wrapping

                        <actinic:block type="ComponentList">

                        </actinic:block>

                        around the

                        <actinic:block type="AttributeList">
                        .
                        .
                        .
                        </actinic:block>

                        And see if that fixes things.
                        Norman - www.drillpine.biz
                        Edinburgh, U K / Bitez, Turkey

                        Comment

                        Working...
                        X