Announcement

Collapse
No announcement yet.

Blocks tutorial 5: Use of custom variables

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

    Blocks tutorial 5: Use of custom variables

    Synopsis
    OK, so we made some lists of products, and we made some clever navigations. What next? Make our own lists!

    Actinic has some marketing features, but it's only got a few types of usable lists in V9/10, namely, the Best Sellers and the New Items. But we can have so much more.

    What about these:
    • Managers specials
    • Sale now on!
    • Price ranges
    • Arbitrary groups of items, such as brands.

    Creating a custom special list
    We're going to create a list to demonstrate this advanced technique. We're going to call it Gabriel's Deals. In it, we'll be creating a special group, and putting some items into it, from our catalog. then, we'll be displaying them in our templates.

    Step 1, making a special variable.
    • Open the library {Design > Library...}
    • Click the Variables tab.
    • Right click in a blank space and click 'New Group'.
    • Call it 'MyLists'
    • Right click on our new group 'MyLists'. Click 'New Variable'


    Name: GabrielsDeals
    Prompt: GabrielsDeals
    Place of setting: Product
    Tab: Marketing
    Type: True/False
    Initial Value: False
    • Click ok, and then 'Close'.

    OK! we just made a new property, that allows us to choose if an item appears in our list. Now, pop into your catalog, and find some products. Go to the 'Marketing' tab and then set a few items to yes. I did about 5ish.

    OK, so what's the code?

    Well, I'll assume that you can now expand on blocks, so I'm only going to give very simple markup, so you can add to it later.

    HTML Code:
    <div>
    <actinic:block type="EntireSectionList" >
    <actinic:block type="ProductList" >
        <actinic:block if="%3cactinic%3avariable%20name%3d%22GabrielsDeals%22%20%2f%3e%20%3d%3d%20true" >
                £<actinic:variable name="ProductPriceRaw" />: <actinic:variable name="ProductName" /><br>    
        </actinic:block>
    </actinic:block>    
    </actinic:block>
    </div>
    OK, so what's going on here? Well first of all, due to the nature of Actinic when we loop a set of products, like this:

    HTML Code:
    <actinic:block type="ProductList" >
    Actinic will list only the products that are in the current scope. That is, only products on the current page. To get around this, we loop all the sections, and then list all the products inside that. Like a loop inside a loop. See? This in effect lists all the products that there are in the shop.

    We needed to limit that, to only products that we have chosen to be in our list. So, we use a simple blockif. that says in English:

    'Show this item if GabrielsDeals is true'.

    So, basically, we only show items in this list, that have this variable set to true. Actinic can deal with lots of these lists. So you can really go to town on the phrases you choose. Managers specials, deals, the lot. Go add some more markup and a link like I showed you earlier, and you have got yourself another marketing concept.

    Did you say price ranges?
    YES! I did. OK, so how do we do this?

    Luckily, we don't need to create a variable for this. We already have one. You have the prices as a part of your products (or you should have).

    OK, so, lets dive in with an example:

    HTML Code:
    <div id="prices">
    <actinic:block type="EntireSectionList" >
    <actinic:block type="ProductList" >
        <actinic:block if="%3cactinic%3avariable%20name%3d%22ProductPriceRaw%22%20%2f%3e%20%20%3c%3d%2015" >
                £<actinic:variable name="ProductPriceRaw" />: <actinic:variable name="ProductName" /><br>    
        </actinic:block>
    </actinic:block>    
    </actinic:block>
    </div>
    How does this work? Well, you may have noticed that the last example included the price of the item in the list too. We can use this price to make comparisons as well.

    Our 'blockif' in this one does not limit to the GabrielsDeals variable, it limits based on the price. In English?
    'Show this item if the price is less than 15'

    Of course depending on your currency, you'll need to change some things, namely the pound sign, but it's the number we're interested in. Using what you've learned earlier, you can easily change the amount that's filtered, or even make a list showing a price range, between two numbers.

    Brand lists?
    The idea for brand lists is a similar one to the last we made first in this tutorial. In this, we have a variable that is of type 'text'. Then we type the brand name in there.

    Assign each product a brand, then create a list like the ones above, that show only those brands that equal a brand you choose. Make a new block for each 'Brand'. When you have a new brand, then make a new block.

    You can use ideas picked up earlier, to make all sorts of lists, and dropdown boxes for this idea, try it.


    With thanks to Gabriel Crowe of Interact Studio
Working...
X