RTML Programming |
RTML is a special programming language used exclusively by Yahoo Ecommerce Stores services.
RTML Operator “AS-LIST”
In an RTML template the newly created operator looks like:
AS-LIST type nil
class nil
id nil
style nil
title nil
This operator insert <ul>….</ul> or <ol>….</ol> lists html tags into the page code. The type of tag depends on the attribute type value, either :оrdered or :unordered
EXAMPLE
AS-LIST type :оrdered
ITEM
TEXT "First Notation"
ITEM
TEXT "Second Notation"
The HTML code will be generated as:
<ol><li>First Notation</li><li>Second Notation</li></ol>
RTML Operator “AND”
In an RTML Template the “AND” operator looks like:
AND
The operator AND may contain operators and arguments. If any of them returns false or nil, then the operator AND returns false (nil). If all arguments return true or contain some values, the operator returns the value of last arguments.
This operator could be used in combination with the “IF”, “WHEN”, “OR” and “WITH=” operators.
EXAMPLES:
IF test AND
@custom-free-shipping
< value1 @ship-weight
value2 2
then TEXT "Free Shipping For This Item"
else nil
In this example, we are verifying if the “Free Shipping” option could be applied for a particular item. If the property @custom-free-shipping is “ON” and the item shipping weight is less than 2 (lb), then the text “Free Shipping For This Item” will appear on the page spot.
IF test AND
@orderable
OR
@sale-price
@price
then TEXT "This is Item"
else nil
In this example we are checking if this is the Item page. If the orderable property is set to the value “Yes” and the sale-price or price is defined, then the text “This is the Product page” will appear on the page spot.
Custom Availability
By default, the Yahoo Store System uses pre-defined “availability” options.
In this article, we will show you how to implement a “Custom availability” text field together with a pre-defined property in your store. You should have basic RTML knowledge to use this method.
In order to define “custom availability”, open a list of store Templates. Within the Custom templates column find the template that corresponds to the Item order (this template is a copy of a default template called Item-order).
In this RTML template find the RTML expression WHEN @availability:
WHEN @availability
DIV class "itemavailable"
TEXT STRING-APPEND
GRAB
TAG tag "em"
TEXT "Availability: "
@availability
In this expression change the variable @availability to customavailability:
WHEN customavailability
DIV class "itemavailable"
TEXT STRING-APPEND
GRAB
TAG tag "em"
TEXT "Availability: "
customavailability
Create a New RTML operator WITH= and paste the above expression into it. In this operator, assign the variable value to customavailability:
WITH= variable customavailability
value nil
WHEN customavailability
DIV class "itemavailable"
TEXT STRING-APPEND
GRAB
TAG tag "em"
TEXT "Availability: "
customavailability
Create a New RTML operator IF to check @custom-availability and @availability fields. Pass IF to WITH= operator:
WITH= variable customavailability
value IF test NONEMPTY @custom-availability
then @custom-availability
else @availability
WHEN customavailability
DIV class "itemavailable"
TEXT STRING-APPEND
GRAB
TAG tag "em"
TEXT "Availability: "
customavailability
Finally, define the custom property @custom-availability (type text) in the item page or at the item type and fulfill it with its necessary value.
RTML Operator “ACCUMULATE”
In an RTML Template, the “ACCUMULATE” operator looks like:
ACCUMULATE result_var nil
iter_var nil
result_init nil
sequence nil
This operator accumulates certain values in result_var. At the beginning of iteration, result_var holds the value of the result_init variable. Sequence holds the list of objects (for example: the list of items). The ACCUMULATE operator takes elements from this list and passes them into iter_var variable one by one. Then the ACCUMULATE operator evaluates the expression assigned within it and passes the result to result_var.
Let’s look at the following example:
WITH= variable maximum-price
value ACCUMULATE result_var maxprice
iter_var item
result_init MINNUM
sequence @contents
MAXIMUM
maxprice
WITH-OBJECT item
ELEMENT position 0
sequence OR
@price
@sale-#price
WITH= variable minimum-price
value ACCUMULATE result_var minprice
iter_var item
result_init MAXNUM
sequence @contents
MINIMUM
minprice
WITH-OBJECT item
ELEMENT position 0
sequence OR
@price
@sale-price
TEXT GRAB
"price from $"
TEXT minimum-price
" to $"
TEXT maximum-price
In this example, we are defining the minimum and maximum price for the products that is in the listing page’s built-in property contents. For this purpose, we are also using RTML operators MINNUM and MAXNUM. They hold the minimum and maximum numbers in the Yahoo store system. If we want to get the minimum price, then we have to determine the maximum value first in result_init , if we want to obtain the maximum item price, then we have to determine the minimum value first in result_init. Within the ACCUMULATE operator we compare item_var and item price. Then the result will passed to item_var
RTML Operator “>” [greater than]
In an RTML Template the “>” operator looks like:
> value1 nil
value2 nil
The purpose of this operator is to compare two numbers. If the first argument is greater than the second one, then the operator returns “true”.
EXAMPLES:
TEXT IF test > value1 @custom-variable
value2 20
then "Your number greater than 20"
else "Your number is less or equal to 20"
As a result, if the number defined in the custom property “custom-variable” will be greater than 20, then the text “Your number is greater than 20” will appear at the page spot, otherwise the text ” Your number is less or equal to 20” will appear.
RTML Operator “<” [less than]
In an RTML Template the “<” operator looks like:
< value1 nil
value2 nil
The purpose of this operator is to compare two numbers. If the first argument is less than the second one, then the operator returns “true”.
This operator could be used in combination with “IF”, “FOR” and “WHEN” operators.
EXAMPLES:
WHEN < value1 @custom-variable
value2 20
TEXT "Your number is less than 20"
So, if the number defined in the custom property “custom-variable” will be less than 20, then the text “Your number is less than 20” will appear at the page spot.
Reasons to turn ON the Advanced Editor Mode
Click the red triangle in the Standard mode Editor Toolbar.
A second bar with additional yellow buttons will appear at the page toolbar:
Contents – to control your store structure (Contents Tree), page dependencies, “Basement” and “Siberia” areas.
Files – access to your store library /lib directory
Templates or page template – access to the last viewed store template (also the “shortcut” to templates library)
Types – access to the list of store page types, either default or custom (editable)
Database Upload – another access to DB upload with a wider list of functions comparatively to DB upload via Catalog Manager
Config – access to store properties
Controls – store editor settings, including the store editor Search page and Edit by ID function
Useful Links & Bookmarks
A list of useful links to Yahoo store resources and other web tools :
Yahoo Help pages for store users: http://help.yahoo.com/help/us/store/edit/index.html
Find broken links on web sites: http://home.snafu.de/tilman/xenulink.html
SEO book: http://www.seobook.com/
Search Engine Keyword Tracker & Keyword Ranking Tool: http://www.digitalpoint.com/tools/keywords/
Search Engine Friendly Redirect Checker: http://www.webconfs.com/redirect-check.php
How is your site viewed by SE crawlers? http://www.delorie.com/web/lynxview.html
Google on-line sitemap generator : http://www.xml-sitemaps.com/
If you have any other resources which might be useful in development and maintenance, please let us know about them!
Editing of RTML templates
Let’s suppose that you’ve just opened a brand new Yahoo store account. You’re excited and ready to put up your items for sale. But hold on a second. Before you upload the inventory items we insist that you follow these steps to create a list of Editable Templates.
By default RTML templates cannot be edited. To be capable of enhancing these templates, you need to make copies of all your base templates. This is a necessary step because afterwards, these template copies and newly created templates will have the possibility of being altered and edited.
As we have already said, you must make this list of Editable Templates before you upload any items because it will help you avoid the process of changing the templates for each item one by one.
So how does someone create a list of Editable Templates?
The first step you must take is to turn on the Advanced Editor Mode in the Control panel.
You will now see a second row of control buttons on the bottom of your main page
-Click on the tab called “Contents”
-In the contents page, click the yellow button named “Templates”
-Once you access this page you will see a list of all the templates.
-Find the template “Storetemplate.” and click to open it.
-Find the “Copy Template” button and click it.
-There will be a field that will appear where you have to type in a name for the new template. An example could be, “New-Storetemplate”
-Click the “Copy” button.
Congratulations. You have successfully created a List of Editable Templates! To recap, this was made possible through a process of copying the parental template (Storetemplate). Afterward, the RTML system automatically copies subsequent templates on it’s own, and all you need to do is apply this new template to your store pages by editing the store properties. This method will benefit you because you will have fewer pages to edit, and your workload will greatly decrease.
For example, let’s edit the first page of the site (Home page). Open up the Home page and click Edit. Then within the “Template” property change Storetemplate to New-Storetemplate and click on the Update button. Do not worry; the page layout will remain the same, because the new template is the exact copy of the old one.
Finally, all you need to do is apply some changes to the Config page. This is marked by a yellow button called “Config” at the top or bottom of your store pages (depending on the page settings).
When you are in the Config page you must edit three drop-down menus (Default-item-template, Default-section-template, Default-group-template) and change Store-template to the new editable template.
As a result of taking these steps you now have the possibility to edit templates and to have all newly created pages under an editable template by default.
In our future articles we will discuss how to improve your Yahoo Store functionality by adding some small changes to the templates.
-Click on the tab called “Contents”
-In the contents page, click the yellow button named “Templates”
RTML Operator “BLUE”
Within Yahoo Store RTML Template, this operator is showing as:
BLUE nil
The operator takes color value and returns its blue component of RGB (red green blue) color model in numeric value between 0 and 255.
EXAMPLES:
WITH= variable blue value BLUE @background-color WITH= variable red value RED @background-color WITH= variable green value GREEN @background-color BODY background-color COLOR red red - 20 green green - 20 blue blue - 20
At this example, we took Red Green and Blue color components from the global variable @background-color. Then, we are using these components to make the body background darker.