Hick Script

Hick Script Vanilo Cloud offers a dead simple scripting syntax (called "Hick Script") that can be used for injecting custom data to template pages.

The script can be placed in configuration values and their result will be available in the given blade/twig templates.

Products, taxonomies and taxons can be injected using this method.

Products

Single or multiple products can be retrieved using the product statements.

By SKU

The product.bySku(SKU-123) method accepts a single SKU as a parameter, and returns the product or variant that has the given SKU. If no result was found, it returns NULL.

{
    "cloud": {
        "home": {
            "inject": {
                "highlighted": "product.bySku(mysku01)",
                "brands": "taxonomy.bySlug(brands)"
            }
        }
    }
}

The example will take the product having SKU mysku01 injects it into the home view as the $highlighted variable:


{{-- home.blade.php --}} <h2>Highlighted Product</h2> @if(null !== $highlighted) <p>{{ product_title($highlighted) }}</p> <a href="{{ url_of($highlighted) }}">Discover</a> @endif

By SKUs

The bySkus method makes it possible to return multiple products/variants using their SKUs:

product.bySkus(sku1, sku2, sku3)

This will return a collection containing the products based on their SKUs.

If any of the products can't be found based on the given SKU, that will be omitted from the results.

If no SKUs were found, an empty collection is returned.

By Slug

The bySlug method returns a single product or a master product based on its slug:

product.bySlug(dell-xps13-laptop)

If no result is found, it returns NULL.

By ID

The byId method returns a single product or master product based on its ID:

product.byId(12)

It attempts to find a product by ID.

If you want to return a master product, pass master as the second parameter:

product.byId(12, master)

This will look up a master product by ID.

If no result is found, it returns NULL.

Latest

The latest method returns the given number products that were created most recently:

product.latest(5)

It will return a collection of (max) 5 products that are the most recent ones.

All

The all method returns all the products and master products from the database that are active.

Use with care! If there's a large number of products it can slow down the page!

Taxons

Single or multiple taxon (category) entries can be returned by the taxon script methods.

Refer to the Categorization page to understand what taxonomies/taxons are

By Slug

The bySlug method returns a single taxon based on its slug:

taxon.bySlug(adidas)

If no result is found, it returns NULL.

Vanilo allows to have identical taxon slugs if the taxons are in different taxonomies (category trees). To distinguish between entries, there's a second, optional parameter, that is the slug of the taxonomy:

taxon.bySlug(adidas, brand)

If you have two different category trees, let's say brand and style, both having adidas as taxon, you can distinguish between the entries:

taxon.bySlug(adidas, brand) vs taxon.bySlug(adidas, style).

If not entry is found based on the parameters, the script returns NULL.

By ID

The byId method returns a single taxon based on its ID:

taxon.byId(12)

If there's no taxon with the given ID, it returns NULL.

By IDs

The byIds method makes it possible to return multiple taxons using their IDs:

taxon.byIds(7, 31, 20, 64)

You can pass two or more taxon IDs, and it will return a collection containing the taxon objects.

If any of the passed IDs has no associated taxon, will be omitted from the results.

If no taxons were found based on the IDs, an empty collection is returned.

Taxonomies

Specific taxonomy (category tree) entries can be returned by the taxon script methods.

Refer to the Categorization page to understand what taxonomies/taxons are

By Name

The byName method returns a single taxonomy based on its name:

taxonomy.byName(Kategorie)

If no result is found, it returns NULL.

By Slug

The bySlug method returns a single taxonomy based on its slug:

taxonomy.bySlug(brands)

If no result is found, it returns NULL.

By ID

The byId method returns a single taxonomy based on its ID:

taxonomy.byId(1)

If there's no taxonomy with the given ID, it returns NULL.