Announcement

Collapse
No announcement yet.

Can you use product images as default section images?

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

    Can you use product images as default section images?

    Hi all,
    Saw a thread on this subject sometime ago though a solution was never posted (Jan at Mole End said she might sort something out).

    I was wondering since we can now push actinic with php whether or not anyone had come up with a labour saving way to create section images (I haven't as yet).

    What I would like to do is for for a section image to be automatically taken from a resized version of the first product found under that section (which as the sites I create tend to use 1 product/page this would be the only product under the the section) the image being a resized version of the main product image (using the resize script in the a.u.g).

    If no product is found then a section image must be created in the standard way furthermore for any image added as a section image to be used instead of an image created from the product image if used.

    Any ideas? Would save oddles of time and make a lot of sense
    Regards
    Bangers
    Boxhedge New Media Design
    Design and development solutions for SME's.
    Tel: 0118 966 2786
    Examples of work can be found at http://www.boxhedge.com

    #2
    Within your Section layout, you can put a block like (pseudo code)

    Code:
    if ( SectionImage != "" )
      {
       // Display Normal Section Image
      }
    if ( SectionImage == "" )
      {
      $noimageyet = true;
      <actinic:block type="ProductList">
         if ( $noimageyet && (ProductImageFileName != "") )
           {
           // Scale and Display Product Image
           $noimageyet = false;
           }
      </actinic:block>
      }
    This deals with cases where there may be several products and the first ones may not contain an image.
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Thanks Norman,
      At least it seems like it should be possible.
      Where abouts in the section layout should the code be placed?
      Also If I have created an image using your image rescale method how would I call the specific resized image?

      Say it was usually called by method:
      <img src="t_<actinic:variable name="ProductImageFileName" />" /

      thanks for the help, I'll post you when I have finshed the site,
      regards
      Bangers
      Boxhedge New Media Design
      Design and development solutions for SME's.
      Tel: 0118 966 2786
      Examples of work can be found at http://www.boxhedge.com

      Comment


        #4
        As it's likely to be a different size from the product image one, I would duplicate the image resize code into the tweak above but call the new image

        s_<actinic:variable name="ProductImageFileName" />
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Hi,
          Thanks for the help but I can't seem to get it to work.
          Even the simple code without the resize tweek and wrapped in:
          <actinic:block php="true">

          </actinic:block>
          returns nothing. Am I missing something?

          Currently my CSS Section Layout looks like this (just to see if I get a result):
          <actinic:block php="true">
          if ( SectionImage != "" )
          {
          // Display Normal Section Image
          }
          if ( SectionImage == "" )
          {
          $noimageyet = true;
          <actinic:block type="ProductList">
          if ( $noimageyet && (ProductImageFileName != "") )
          {
          // Scale and Display Product Image
          $noimageyet = false;
          }
          </actinic:block>
          }
          </actinic:block>
          <div class="product_list">
          <div class="image_product"><a href="<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" target="_self">
          <img border="0" alt="<actinic:variable name="SectionName" encoding="strip"/>" src="<actinic:variable name="SectionImageFileName" />" /></a></div>
          <div><h3 class="product"><a href="<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" target="_self"><actinic:variable name='SectionName'/></a></h3></div>
          <p><actinic:variable name='SectionDescription'/></p>
          </div>
          But nothing appears, I know I am missing something any help from anyone (don't want to keep burdening Norman) would be appreciated,
          regards
          bangers
          Boxhedge New Media Design
          Design and development solutions for SME's.
          Tel: 0118 966 2786
          Examples of work can be found at http://www.boxhedge.com

          Comment


            #6
            I posted "Pseudo Code". That means you cannot use it as-is and expect it to work. You are expected to do the donkey-work yourself.

            I.e. The items SectionImage and ProductImageFileName would need to be replaced with the relevant Actinic Variables (within single quotes and with attributes encoding="perl" selectable="false" ).

            Also you need to put the relevant code where

            // Display Normal Section Image

            and

            // Scale and Display Product Image

            is.
            Norman - www.drillpine.biz
            Edinburgh, U K / Bitez, Turkey

            Comment


              #7
              I've just updated the original patch as the Advanced Guide one was a bit restrictive. See http://community.actinic.com/showthread.php?t=34654 for the newer version.
              Norman - www.drillpine.biz
              Edinburgh, U K / Bitez, Turkey

              Comment


                #8
                Hi,
                I have done the tweeks but whilst the standard section images displays fine the one's trying to use an image from the product do not (returning the standard default image for when there is no section image selected).

                Here's the code:
                <actinic:block php="true" >
                if ( '<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />' != "" )
                {
                echo "<img src=\"<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />\" width=\"<actinic:variable name="SectionImageWidth" />\" height=\"<actinic:variable name="SectionImageHeight" />\" border=\"0\" />";
                }
                if ( '<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />' == "" )
                {
                $noimageyet = true;
                <actinic:block type="ProductList" >
                if ( $noimageyet && ('<actinic:variable encoding="perl" name="ProductImageFileName" selectable="false" />' != "") )
                {
                echo "<img src=\"<actinic:variable name="ProductImageFileName" />\" border=\"0\" />";
                $noimageyet = false;
                }
                </actinic:block>
                }
                </actinic:block>
                At the moment I am keeping it simple and seeing if I can just get the product image to pass to the section page (I will add the resizing later).
                I take it I am missing something agian but I would really appreciate it if anyone can see where I am going wrong,
                regards
                Bangers
                Boxhedge New Media Design
                Design and development solutions for SME's.
                Tel: 0118 966 2786
                Examples of work can be found at http://www.boxhedge.com

                Comment


                  #9
                  The default section image was messing things up. Some tweaks were needed. This works for me
                  Code:
                  <div class="product_list">
                   <div class="image_product">
                    <a href="<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" target="_self">
                     <actinic:block php="true" >
                  	$noimageyet = true;
                  	// if non-default image use it
                  	if ( basename('<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />') != basename('<actinic:variable name="DefaultSectionImage" encoding="perl" selectable="false" />') )
                  		{
                  		$noimageyet = false;
                  		echo "<img src=\"<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />\" width=\"<actinic:variable name="SectionImageWidth" />\" height=\"<actinic:variable name="SectionImageHeight" />\" border=\"0\" />";
                  		}
                  	// otherwise look for a product image to use
                  	else
                  		{
                  		<actinic:block type="ProductList" >
                  		if ( $noimageyet && ('<actinic:variable encoding="perl" name="ProductImageFileName" selectable="false" />' != "") )
                  			{
                  			echo "<img src=\"<actinic:variable name="ProductImageFileName" />\" width=\"50\" border=\"0\" />";
                  			$noimageyet = false;
                  			}
                  		</actinic:block>
                  		}
                  	// if no section or product image, use default Section one
                  	if ( $noimageyet )
                  		{
                  		echo "<img src=\"<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />\" width=\"<actinic:variable name="SectionImageWidth" />\" height=\"<actinic:variable name="SectionImageHeight" />\" border=\"0\" />";
                  		}
                     </actinic:block>
                    </a>
                   </div>
                   <div>
                   <h3 class="product"><a href="<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" target="_self"><actinic:variable name='SectionName'/></a></h3>
                   </div>
                   <p><actinic:variable name='SectionDescription'/></p>
                  </div>
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    I've posted the all-singing rescaling version on http://community.actinic.com/showthread.php?p=208421
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      A thing of beauty,
                      cheers
                      Bangers
                      Boxhedge New Media Design
                      Design and development solutions for SME's.
                      Tel: 0118 966 2786
                      Examples of work can be found at http://www.boxhedge.com

                      Comment


                        #12


                        I can't get this to work.

                        The main part of my section link layout is as follows

                        Code:
                        <div class="product_list" align="center" style="border: 1px solid <actinic:variable name="Palette2" />; padding: 5px;">
                        <div><h3 class="product"><a href="<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" target="_self"><span style="color:<actinic:variable name="Palette2" />"><actinic:variable name='SectionName'/></span></a></h3></div>
                          <a href="<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" target="_self">
                           <actinic:block php="true" >
                        	$noimageyet = true;
                        	// if non-default image use it
                        	if ( basename('<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />') != basename('<actinic:variable name="DefaultSectionImage" encoding="perl" selectable="false" />') )
                        		{
                        		$noimageyet = false;
                        		echo "<img src=\"<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />\" width=\"60\" border=\"0\" />";
                        		}
                        	// otherwise look for a product image to use
                        	else
                        		{
                        		<actinic:block type="ProductList" >
                        		if ( $noimageyet && ('<actinic:variable encoding="perl" name="ProductImageFileName" selectable="false" />' != "") )
                        			{
                        			echo "<img src=\"<actinic:variable name="ProductImageFileName" />\" width=\"50\" border=\"0\" />";
                        			$noimageyet = false;
                        			}
                        		</actinic:block>
                        		}
                        	// if no section or product image, use default Section one
                        	if ( $noimageyet )
                        		{
                        		echo "<img src=\"<actinic:variable encoding="perl" name="SectionImageFileName" selectable="false" />\" width=\"60\"  border=\"0\" />";
                        		}
                           </actinic:block>
                          </a>
                        <actinic:block type="ProductList" >
                        <actinic:block if="%3cactinic%3avariable%20name%3d%22IsAddToCartButtonShown%22%20%2f%3e%20AND%20%0d%28%3cactinic%3avariable%20name%3d%22NumberAttributesInPushButtonGrid%22%20%2f%3e%20%3d%3d%200%29" >
                        <actinic:block type="PriceList" ><actinic:variable name="PriceLayout" value="Standard Tax Inclusive Price" />
                        </actinic:block>
                        </actinic:block><br/>
                        <span class="actrequired"><Actinic:Variable Name="QuantityPrompt"/></span>
                        <input type="text" name="Q_<Actinic:Variable Name="ProductReference"/>" size="4" value="<Actinic:Variable Name="DefaultQuantity"/>" class="form_input_general" />
                        <actinic:variable name="AddToCartButton" />
                        </actinic:block> 
                        <a href="<actinic:block if="%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20AND%0d%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e" ><actinic:variable name="SectionPageName" /></actinic:block><actinic:block if="%28%3cactinic%3avariable%20name%3d%22IsLoginPageSuppressed%22%20%2f%3e%20%3d%3d%20false%29%20OR%0d%28%3cactinic%3avariable%20name%3d%22UnregCustomersAreNotAllowed%22%20%2f%3e%20%3d%3d%20false%29" ><actinic:variable name="SectionURL" /></actinic:block>" target="_self">More Info...</a>
                        </div>
                        For some reason, when an image isn't specified for the section, it's still using the default image and NOT the section image. Having said that, it's not a default image as set in Site Options, it's using the image from its parent section and I can't work out how to stop it doing.
                        I'm probably having a blonde moment but if someone could point me in the right direction, I'd be really grateful

                        I don't want it to do away with using the parent section image sitewide, otherwise I might have attempted the workaround given HERE but for the sections I'm putting these section links in, it is causing me a problem
                        Tracey

                        Comment


                          #13
                          just to add...I've also tried replicated the method as it is given HERE but it still uses the parent section's image by "default" and not the product image
                          Tracey

                          Comment


                            #14
                            Nothing wrong with the code you've posted as far as I can tell, I just tried it on my site and it works fine.
                            Maybe you've missed something else in the setup.
                            Have you created the directory for the thumbnails?
                            Are all images jpgs?
                            Are you calling the custom layout into the new page layout?
                            Have you setup the variables correctly?

                            Good Luck
                            Bangers
                            Boxhedge New Media Design
                            Design and development solutions for SME's.
                            Tel: 0118 966 2786
                            Examples of work can be found at http://www.boxhedge.com

                            Comment


                              #15
                              Tracey,
                              Sorry!
                              You are right. I got a bit mixed up about what you were saying when you said
                              it's still using the default image and NOT the section image
                              I now realise when you said "default image" you meant it was defaulting to the parent section image.
                              The same thing is happening to me, by default when a parent section image is present it replaces the sub section image with that rather than the product image.

                              It won't really cause me too many problems for me as my catalogue layout is:
                              Section
                              Product
                              Subsection
                              Product
                              Subsection
                              Product
                              Subsection
                              Product

                              (so I can do away with parent section images and have images generate from the single product image found directly under it, keeping the sub sections happy). However if my catalogue was set up:
                              Section

                              Subsection
                              Product
                              Subsection
                              Product
                              Subsection
                              Product

                              (without product on same level as sub sections)
                              then I can see where this would cause a problem if a section image was present and I wanted sub section images to generate from their containing product images.

                              It would also cause a problem if I did away with section images altogether as the section wouldn't have a product to generate an image from so would show the default image for no image found when you opened the full catalogue view.

                              Hopefully someone can solve this.
                              Boxhedge New Media Design
                              Design and development solutions for SME's.
                              Tel: 0118 966 2786
                              Examples of work can be found at http://www.boxhedge.com

                              Comment

                              Working...
                              X