Announcement

Collapse
No announcement yet.

Test for Fragment at Section Level

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

    Test for Fragment at Section Level

    Hello....

    Could someone provide some assistance with testing whether a section has a fragment or not?

    Something very similar to the
    <actinic:variable name="SectionHasVisibleProduct" />
    variable would be awesome, just need it to tell me whether there's a fragment or not instead.

    All help much appreciated....

    Regards,

    Guy
    Regards,

    Guy

    Lead Developer - Lock Shop Warehouse
    Offering discounted padlocks, and a huge range from the best door lock suppliers, all alongside other essential security products.

    #2
    It depends on where you need this condition.

    e.g. if you wanted to show if it had fragments or not inside that section's link layout then you could use a simple:

    Code:
            <actinic:block type="ProductList" >
                <actinic:block if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%202" >
                    HERE BE FRAGMENTS
                </actinic:block>
            </actinic:block>
    which will spit something out for each fragment inside that section.

    You could adapt this with a true/false PHP variable which could be used to determine if there were any fragments in the section and then do something accordingly.

    The key point is that fragments and products are both looped through in the ProductList. The difference is products and duplicates have their ProductType property set to 0 and 1 respectively. Fragments have a ProductType equal to 2.

    This may help you some of the way....
    Fergus Weir - teclan ltd
    Ecommerce Digital Marketing

    SellerDeck Responsive Web Design

    SellerDeck Hosting
    SellerDeck Digital Marketing

    Comment


      #3
      Hey Fergus,

      Thanks for the advice, I've put something together which is doing the job. It shows a SectionTitle & SectionDescription if no fragment or products are on the page.

      I'm going to paste the code. Although it works I'm not sure i've nailed the way things are done in Actinic so it's here incase you, or anyone else, can offer any advice on how to improve it.

      Code:
      <actinic:block php="true" >
      	$frag = 0;
      </actinic:block>
      	
      <actinic:block type="ProductList" >
      <actinic:block if="%3cactinic%3avariable%20name%3d%22ProductType%22%20%2f%3e%20%3d%3d%202" >
      	<actinic:block php="true" >
      		$frag = 1;
      	</actinic:block>
      </actinic:block>
      </actinic:block>
      	
      <actinic:block if="%3cactinic%3avariable%20name%3d%22SectionHasVisibleProduct%22%20%2f%3e%20%3d%3d%20false">
      	<actinic:block php="true" >	
      		if ($frag == 0) echo "<h1><actinic:variable name="SectionName" /></h1><p class=\"sectionDesc\"><actinic:variable name="SectionDescription" /></p>";
      	</actinic:block>
      </actinic:block>
      Guy
      Regards,

      Guy

      Lead Developer - Lock Shop Warehouse
      Offering discounted padlocks, and a huge range from the best door lock suppliers, all alongside other essential security products.

      Comment

      Working...
      X