Announcement

Collapse
No announcement yet.

Testing Section name with BlockIF

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

    Testing Section name with BlockIF

    Referring to the attached image, what I'd like to do is test if a Product 'A' is under Section 'B' and if so add some text below the price on that product.

    For example, if the Product is under Baglux.htm, then Show the text 'Free Delivery' beneath the price.

    I've searched and been through the AUG and Gabe's tutorial, but can't discover which variable to test.

    Thanks IA
    Attached Files
    Kind Regards
    Sean Williams

    Calamander Ltd

    #2
    Here's my take on it, example shows pseudocode of the product (ref: 6789) in section with ID #3.

    blockif sectionid == '3'
    blockif productid == '6789'
    <div class="free_delivery">
    Some text here if you want it
    </div>
    /block
    /block

    This would, in theory, only show the 'free delivery' div (CSS controlled to show the image/layout, or even text) based on the SectionID being 3 AND ProductID being 6789.

    Shouldn't be difficult to code but I ain't got Actinic on this machine

    Comment


      #3
      Code:
      <actinic:block if="%3cactinic%3avariable%20name%3d%22SectionID%22%20%2f%3e%20%3d%3d%20%273%27">
      	<actinic:block if="%3cactinic%3avariable%20name%3d%22ProductID%22%20%2f%3e%20%3d%3d%20%276789%27">
      		<div class="free_delivery">
      		Here's some text
      		</div>
      	</actinic:block>
      </actinic:block>
      This will only show the image/text if productid 6789 is shown under section with id 3. Though productid 6789 is unique so technically you wouldn't need the first block around it.

      I actually set this up on CGC a long time ago, using the following, which checks if shipping charges are made - ie. the 'free shipping' method is only shown if the product doesn't have shipping charges - it doesn't work these days as we now use the global shipping costs settings - back in those days, the site was set up with shipping costs defined at product level.
      Code:
      <actinic:block if="%3cactinic%3avariable%20name%3d%22ShippingChargesAreMade%22%20%2f%3e%20%3d%3d%20%27False%27">
      		<div class="free_delivery">
      		Here's some text
      		</div>
      </actinic:block>

      Comment


        #4
        Thanks Grant
        I can see where your code is going, but it's not quite what I'm after.

        Edit: The product A is non-specific; it can be any product beneath the section 'Baglux'

        The test I need is whether the current product shown is under the [is 'Parent' the correct terminology] section with name 'Baglux'.
        Is there a clue on your use of the sectionid being '3' ?

        In the example image attached, would the section named Baglux be known as sectionid '0'?

        If so, how can it be tested if sectionid '0' == (sectionname == 'baglux') if you see what I mean?
        Kind Regards
        Sean Williams

        Calamander Ltd

        Comment


          #5
          Sorry Sean - the SectionID is created automatically, the only way to 'see' the SectionID is to add the variable to your layout - I have it added in a blockif:
          Code:
          <actinic:block if="%3cactinic%3avariable%20name%3d%22IsPreviewMode%22%20%2f%3e%20%3d%3d%20true">
          	<actinic:variable name="SectionID" />
          </actinic:block>
          Obviously this means it is shown in Preview but not on the live site. I chose SectionID and ProductID of 3 and 6789 randomly, they bear no significant meanings.

          Presuming you never delete section 'Bagflux' and recreate it, the sectionID will never change. You may then be able to adapt the code in my first post to use the SectionID you find when you drop the code above into your 'Section' layout. View the Preview of your site and you will see a number wherever you have dropped the code into the layout, I always put it at the bottom to make life easier - this is the SectionID.

          As the section name can easily be changed, I wouldn't advise using it. The SectionID is as near as permanent as you'll ever get.

          You could always create a layout for the 'free delivery' part, and drop it into your product layout, surround that with a blockif which tests for a custom variable set at product level - you can then set this to 'true' or 'false' at product level - ie. hide or show. Unless of course you want this to be automated for 'Product A' found under section named 'Bagflux'.

          ---------------------------------------------------------------

          Off topic, please add your vote to have sectionID added to the Section Details tab. If anything, it'd make half my above post unnecessary to describe!

          Comment


            #6
            Sean,

            You could also define a specific content category and test this to indicate "free delivery".
            Alan Johnson

            Quality Parrot Cages & Accessories by Parrotize UK
            Pet Accessories by Animal Instinct

            Comment


              #7
              Thanks very much for your help chaps.

              Regarding the content category - any idea what I test for - name of a variable or something?

              Cheers
              Kind Regards
              Sean Williams

              Calamander Ltd

              Comment


                #8
                You first need to set additional content categories under Design> content categories.

                Then you can test with block if:
                ContentCategory == 'FreeDelivery'
                or similar.

                Then select content category on section general tab
                Alan Johnson

                Quality Parrot Cages & Accessories by Parrotize UK
                Pet Accessories by Animal Instinct

                Comment


                  #9
                  Originally posted by animal dreams View Post
                  ContentCategory == 'FreeDelivery'
                  That's what (I think) I was looking for!
                  I'll give it a whirl later.

                  Thanks Alan
                  Kind Regards
                  Sean Williams

                  Calamander Ltd

                  Comment

                  Working...
                  X