Announcement

Collapse
No announcement yet.

creating a list by product group different odd or even?

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

    creating a list by product group different odd or even?

    Hi All,
    I am creating a list according to a product group i have set, no problem there.

    However i would like to use a different class in my div tag depending on wether the product is either an odd number in the list or an even number.

    So i format differently depending on wether 1,3,5,7 in list or 2,4,6,8 etc.

    My odd aligning left with padding and my evens aligning right without padding for an example.

    Any ideas if i can do this? or do I need two seperate product groups and a bit more tinkering which would be a bit of a shame to have to do this.

    Help appreciated as ever,
    Cheers
    Lee
    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
    Product (and Fragments) are laid out by an Actinic List. You can use the ListIndex variable and a bit of PHP within a Condition to detect whether it's odd / even and output code as required.
    Code:
    <actinic:block if="%3cactinic%3avariable%20name%3d%22ListIndex%22%20%2f%3e%20%26%201" >
    	<actinic:variable name="ListIndex" /> is ODD
    </actinic:block>
    <actinic:block if="%21%20%28%3cactinic%3avariable%20name%3d%22ListIndex%22%20%2f%3e%20%26%201%29" >
    	<actinic:variable name="ListIndex" /> is EVEN
    </actinic:block>
    The PHP within the condition is a simple boolean and with 1.

    <actinic:variable name="ListIndex" /> & 1

    and

    ! (<actinic:variable name="ListIndex" /> & 1)
    Norman - www.drillpine.biz
    Edinburgh, U K / Bitez, Turkey

    Comment


      #3
      Cheers norman, does this apply to a product group which may have products from many different sections/sub sections?

      (If so great, I'll just have to find the php to detect the difference.) Scrap that, your a star

      Cheers Lee
      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
        No idea. Try it and see. My example above simply displays the word ODD or EVEN.

        P.S. Edited my post above to use a boolean AND rather than Modulus 2 as AND'ing is faster.
        Norman - www.drillpine.biz
        Edinburgh, U K / Bitez, Turkey

        Comment


          #5
          Actually, no it doesn't but I'll have another go.
          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
            Tag the odd or even text onto the end of class name used, ie

            lee(Odd) {}

            lee(Even) {}

            etc.

            Comment


              #7
              hi lee,
              thanks already have classes setup, i simply add another class to the div if it is odd.

              haven't got the code to work yet mind you so maybe it doesn't apply to a product group, can you think of another way I could differentiate?

              using norman's code above, if i were to want just odd or even to appear - I am only getting ODD returned.
              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


                #8
                Are we talking the product group number or the sequence of the product on the page?

                Comment


                  #9
                  Works for me in a Product Layout. You're not telling where you've put the code so it's difficult to comment.
                  Norman - www.drillpine.biz
                  Edinburgh, U K / Bitez, Turkey

                  Comment


                    #10
                    I've amended my post #2 to display the ListIndex variable alongside the Odd / Even result. That may help you see what's going wrong.
                    Norman - www.drillpine.biz
                    Edinburgh, U K / Bitez, Turkey

                    Comment


                      #11
                      Hi Lee,
                      Product group has already been determined and is what is selecting the few products in the list.

                      What i am trying to do is to take that list and publish them in a sequence that gives ever other product in the list an extra css class.

                      Example
                      So by default all:
                      <div class="all">

                      But ever other take the above and add an extra class:
                      <div class="all extra_class">
                      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
                        If its every other product you want to do that, then why not use the odd/even feature of the list layout?

                        Comment


                          #13
                          Ah yes, lee good lateral thinking, i could do it this way providing i can get it t work inside the blocks to produce the list in the first place (I've never done this before). Cheers

                          Norman - My list returns:
                          1 is ODD
                          5 is ODD
                          5 is ODD
                          1 is ODD

                          and exactly matches where they appear in their respective section/category lists
                          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


                            #14
                            Works for me in a Product Layout. You're not telling where you've put the code so it's difficult to comment.
                            Hi Norman i have created a custom layout which will appear on the homepage only. List is pulled in between the follwing:

                            <actinic:block type="EntireSectionList" >
                            <actinic:block type="ProductList" >
                            <actinic:block if="%3cactinic%3avariable%20name%3d%22GroupID%22%20%2f%3e%20%3d%3d%201" >
                            ---Product layout code here---<+ your code determining odd or even>
                            </actinic:block>
                            </actinic:block>
                            </actinic:block>
                            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
                              Lee -
                              If its every other product you want to do that, then why not use the odd/even feature of the list layout?
                              I'm trying to but i can't think how i can use a standard list layout - unless i can somehow add my "custom featured product list" to the existing list types found in the drop down when you choose> layouts>new layout type>layout type = list and get to choose productlist attributelist etc.

                              Otherwise where would I be able to select product group 1 only?
                              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