JomGenius Parameters

E-mail
(1 vote, average 5.00 out of 5)

 

On this page:

 

JomGenius “core” object

Methods

The “core” object responds to three methods: inTimeSpan(), info(), and check().

inTimeSpan( string ) method

The inTimeSpan() method makes it easy to calculate whether the local time and/or day of the week and/or day of the month is between two days/dates and times. It’s great for timing parts of your site to be active at certain times on certain days.

You just need to give it a single string argument – the time period. It also needs to know the current time zone. This defaults to the current Joomla time zone, but you can set an alternative time zone in MetaTemplate "Parameters", that respects daylight savings time in the chosen locale.

You can even stack more than one time period into the same call, separated with semicolons (;).

The time period can be in any of the following forms:

use form example description
Single day of the week DDD mon Returns "true" from 00:00:00 to 23:59:59 on the chosen day. Day names are the 1st 3 letters in English, lower case.
Several consecutive days of the week DDD - DDD sat - mon Returns "true" from 00:00:00 on the first day to 23:59:59 on the second day. The second day can be in the next week (it rolls over).
A certain time on one day of the week, to a certain time on another day of the week DDD hh:mm - DDD hh:mm mon 09:00 - wed 13:30 Returns "true" from the given time on the first day, to the given time on the second day. You can specify just the day name, or the day and hour, or the day, hour and minutes.
DDD hh:mm:ss - DDD hh:mm:ss mon 09:00:30 - wed 13:30:30
An entire month MMM aug Returns "true" for the entire calendar month (midnight at the beginning of the first day, to midnight at the end of the last day). The month name is lower case, 1st 3 letters of English month name.
A day of the month MMM jj aug 2 Returns "true" for the exact day of the month, from midnight to midnight. The day of the month must not have a leading 0.
Several months MMM - MMM jan - mar Returns "true" for the entire months, from midnight at the end of the first to midnight at the end of the last.
Days of the month with optional times MMM jj hh:mm - MMM jj jan 3 14:30 - mar 3 13:30 Returns "true" between the dates and times specified.
MMM jj hh:mm:ss - MMM jj hh:mm:ss
jan 3 14:30:30 - mar 3 13:30:30
MMM jj - MMM jj hh:mm:ss jan 3 - mar 3 13:30:30
Times of the day (repeated every day) hh:mm 14:01 Returns "true" for the exact minute given.
hh:mm:ss 14:01:29 Returns "true" for the exact second given. [would anyone use that?]
hh:mm - hh:mm 23:30 - 01:00 Returns "true" for the time period given, and operates every day of the week. The period can span midnight. The "seconds" value is optional on both the "from" and "to" times. All times are in the 24-hour clock. All hours are 2-digit.
hh:mm - hh:mm:ss 00:10 - 00:15:30
hh:mm:ss - hh:mm:ss 00:10:30 - 00:15:30

 

Examples:

if ($core_genius->inTimeSpan( "mon; wed; fri") )    echo "It's either Monday, Wednesday or Friday";
if ($core_genius->inTimeSpan( "tue; thur" ) )       echo "It's either Tuesday or Thursday";
if ($core_genius->inTimeSpan( "sat - sat 12:00") )  echo "It's Saturday morning";
if ($core_genius->inTimeSpan( "sat 12:00 - sun" ) ) echo "It's Saturday afternoon or anytime Sunday";

 

info() and check() methods for “core”

The following parameters can be used to get information from the JomGenius “core” object.

e.g. $core_genius->info( "parameter" ) or $core_genius->check( "parameter = value")

parameter description type return values
pagetype This parameter knows about all of the major page types in an out-of-the-box Joomla site. It’s not just restricted to component types, either. e.g. it knows the difference between the search page, and the search results page (after someone has initiated a search).
string
This is the full list of possible results:

Content:

  • frontpage, articleedit, articlesubmit, sectionblog, sectionlist, categoryblog, categorylist, archive

Users:

  • reset, remind, register, login, user

Contacts:

  • contact, contactcategory

Web Links:

  • weblinkscategories, weblinkscategory, weblinkform

Polls:

  • poll

Search:

  • search, searchresults

News Feeds:

  • newsfeedscategories, newsfeedscategory, newsfeed
browser Contains the browser type (lower case), and in some cases the major version number. string
This is the full list of possible results:

Browsers with version numbers (X signifies the version number):

  • firefoxX, ieX, chromeX, operaX, omniwebX, safariX

All others:

  • ipod, iphone, ipad, android, googlebot, google mediapartners, yahoo slurp, msnbot, teoma, playstation, wii
browsertype Contains only the browser type, and not any version numbers. string This is the full list of possible results:
  • firefox, ie, chrome, opera, omniweb, ipod, iphone, ipad, android, googlebot, google mediapartners, yahoo slurp, msnbot, teoma, playstation, wii, safari
browserversion The entire version number of the browser, as well as can be detected. i.e. it's not just the major version number as given in "browser", and may contain "dot" versions. string
JomGenius can detect version numbers for the following browsers only:
  • IE, Firefox, Opera, Chrome, OmniWeb, Safari (not including iPod, iPhone, iPad)

Example of output on IE 5.5:

5.5
browseros The operating system of the platform running the browser, where possible to determine string This is the full list of possible results:
  • windows, mac, linux, bot, console (i.e. gaming console)
referrer The refer(r)er of the currently-viewed web page. Note: this can be spoofed. string http://www.example.com/some/page
domain The domain name used to obtain the current page. string www.example.com
url (also avalable as uri) The full URL used to obtain the current page string http://www.example.com/this/page.html
clientip IP address of the client. JomGenius attempts to detect the IP address used when the client is behind a proxy. As a side-effect of this, this value can be spoofed. string 12.34.56.78
issecure Whether HTTPS has been usede to get the current page. boolean true (if https is used)
false (if http is used)
browserlanguage The language code given by the browser as the preferred language. Can be in the form xx-xx or just xx. string en
frontendlanguage The front-end language of the site. If using JoomFish or similar, the user may have the option of changing this. Always in the form xx-xx. string en-gb
userid The user id of the user, if logged-in. Otherwise 0. string 62
userfullname Full name of the user, if logged in. Otherwise empty string. string Joe Bloggs
userloginname Login name of the user, if logged in. Otherwise empty string. string joeb
useremail E-mail address of the user, if logged in. Otherwise empty string. string This e-mail address is being protected from spambots. You need JavaScript enabled to view it
isloggedin true if user is logged in, otherwise false boolean true
isnotloggedin false if user is logged in, otherwise true boolean true
isguest same as "isnotloggedin" boolean true
userlastvisitdate The date-time stamp for the user's last visit string 2010-07-25 20:55:08
userregisterdate The date-time stamp for when the user registered string 2010-07-19 03:56:04
minutessincelastvisit Number of minutes since this user last visited (only applicable once user has logged in) integer 31
minutessinceregistration Number of minutes since this user registered (only applicable once user has logged in) integer 24601
dayssincelastvisit Number of days since this user last visited (only applicable once user has logged in) integer 0
dayssinceregistration Number of days since this user registered (only applicable once user has logged in) integer 17
group User group the the user is in. 3rd-party ACL extensions may add additional group names – standard Joomla! groups are listed here. string All standard Joomla groups:
  • Registered, Author, Editor, Publisher, Manager, Administrator, Super Administrator

 

Examples:

if ( $core_genius->check( "dayssincelastvisit > 30" ) )
        echo "Welcome back, haven't seen you for a while";
 
if ( $core_genius->check( "browserlanguage starts with fr" ) )
        echo "Bonjour!";
 
if ( $core_genius->check( "browser = ie" )
        and $core_genius->check( "browserversion <= 6" ) )
          echo "Please upgrade your browser!";
 
if ( $core_genius->info( "isloggedin" ) == true )
        echo "Welcome " . $core_genius->info( "userfullname");

 

JomGenius “menu” object

Methods

The “menu” object responds to two main public methods: info(), and check().

info() and check() methods for “menu”

The following parameters can be used to get information from the JomGenius “menu” object.

e.g. in $menu_genius->info( "parameter" ) or in $menu_genius->check( "parameter = value")

parameter description type return values
itemid The "Itemid" of the current menu item, or empty string if none can be detected. string e.g. 5
menutype The menu type for the menu of the currently-active item. string

e.g. mainmenu

e.g. topmenu

name The name of the menu item string e.g. Contact Us
alias The alias of the menu item. This is often used (e.g. in standaard Joomla SEF) as the SEF slug for the page. string e.g. contact-us
type The type of item that this menu links to. The complete set of values is listed on the right. string This is the full list of possible results:
  • component, menulink, separator, url
level The level of menu item. 0 refers to an item at the top level of a menu; 1 is 1st level below that, etc. string e.g. 1
parentitemid The Itemid of the "parent" menu item for the current page string 14
parentitemids An array of all the "parent" menu items for the current page, up to the top level. This can be used to find out if the current page is beneath/within a particular parent menu item. array of strings array("14","16","30")
ispublished Is the menu item corresponding to the current Itemid actually published? boolean true
isdefault Is the menu item corresponding to the current Itemid the "default" menu item for the site? i.e. the default menu item is the one displayed when no other page is requested, e.g. www.example.com boolean true

 

Examples:

if ( $menu_genius->check( "level = 0" ) )
        echo "We are on a top level menu item";
 
if ( $menu_genius->check( "menutype = some of mainmenu, topmenu" ) )
        echo "We're on a page on the main menu or top menu";
 
echo "The current menu item name is " . $menu_genius->info( "name" );
 
if ( $menu_genius->check( "some of parentitemids = 14" ) )
        echo "The current menu item is beneath menu item #14";
 
if ( $menu_genius->check( "parentitemid = 14" ) )
        echo "The current menu item is a direct child of menu item #14";

 

JomGenius “content” object

Methods

The “content” object responds to two main public methods: info(), and check().

info() and check() methods for “content”

The following parameters can be used to get information from the JomGenius “content” object. This object contains a lot of information about the currently-displayed article, category or section, when articles/categories/sections are being displayed.

e.g. in $content_genius->info( "parameter" ) or in $content_genius->check( "parameter = value")

parameter description type return values
pagetype Contains information about the current page type, but only when it's article-related String This is the full list of possible results:
  • frontpage, articleedit, articlesubmit, sectionblog, sectionlist, categoryblog, categorylist, archive
page_number The page number of a multi-page article or section/category list/blog page. 0= first page. This is useful for targetting the 1st page of a paginated webpage.
string 0
article_id The article id (article view pages only)
string 123
article_title The article title (article view pages only)
string Welcome to Joomla
article_alias The article alias (article view pages only) string welcome-to-joomla
article_hits The number of hits the article has received (if this is being tracked) (article view pages only) string 234
article_version The version number of the article. Each time an article is edited, 1 is added to this number for that article. (article view pages only) string 1
article_created_by The user id of the user who first created the article (article view pages only) string 62
article_modified_by The user id of the user who last modified the article (article view pages only) string 62
article_introtext The full intro text of the article (article view pages only) string "This is the intro text of the article..."
article_fulltext The fulltext of the article, as retrieved from the database. i.e. it does not have any plugins applied to this text. (article view pages only) string "The full text of the article..."
article_created The date/time of the creation of the article (article view pages only) string 2004-08-10 06:30:34
article_modified The date/time of the last modification of the article (article view pages only) string 2007-11-08 12:19:35
article_publishup The date/time that the article should begin publishing. "0000-00-00 00:00:00" is used for "no start date". (article view pages only) string 2009-10-25 22:06:47
article_publishdown The date/time that the article should stop publishing. "0000-00-00 00:00:00" is used for "no end date". (article view pages only) string 0000-00-00 00:00:00
article_metakeywords The meta-keywords for an article, as given in the database. i.e. not added by any 3rd-party component for this page (article view pages only) string list,of,keywords
article_metadescription The meta-description for an article, as given in the database. i.e. not added by any 3rd-party component for this page (article view pages only) boolean "This is the metadescription for this article..."
article_created_age The age of the currently-displayed article IN MINUTES since article creation (article view pages only) string 24601
article_modified_age The age of the currently-displayed article IN MINUTES since last modification (article view pages only) string 61
article_frontpage Has the currently-displayed article been assigned to the FrontPage view? (article view pages only) boolean true
category_id The category id of the article, when viewing an article, or the category id of the page for category blog/list pages. string 5
category_title The title of the category. On category blog/list pages, this is the title of the category displayed; on article pages, it's the category title of the article displayed.
string The News
category_alias The alias/slug of the category. On category blog/list pages, this is the alias of the category displayed; on article pages, it's the category alias of the article displayed. string the-news
category_count unknown (just gives the value from the database category table) string
section_id The section id of the article, when viewing an article, or the section id of the page for category blog/list pages. string 6
section_title The title of the section. On Section blog/list pages, this is the title of the section displayed; on article pages, it's the category of the article displayed. string General
section_alias The alias/slug of the section. On section blog/list pages, this is the alias of the section displayed; on article pages, it's the section alias of the article displayed. string general
section_count unknown (just gives the value from the database category table) string

 

Examples:

if ( $content_genius->check( "pagetype = frontpage" ) )
        echo "Welcome to our site";
 
if ( $content_genius->check( "article_created_age > " . 60*24*365 ) )
        echo "This article may be out of date";
 
// MetaTemplate rule to show different template for categories 3, 4, 5 and 7
if ( $content_genius->check( "category_id = 3, 4, 5, 7" ) ) return true;
 
if ( $content_genius->check( "article_hits > 1000" ) )
        echo "POPULAR";
 
// MetaTemplate rule to use different template for articles with certain keyword
if ( $content_genius->check( "article_metakeywords contains MYKEYWORD" ) )
        return true;
 
// MetaTemplate rule to use different template after the 1st page of an article
if ( $content_genius->check( "pagetype = article" )
     and $content_genius->check( "page_number > 0" ) )
        return true;
 
if ( $content_genius->info( "article_created_by" ) ==
     $core_genus->info( "userid" ) )
        echo "Welcome, article author!";

 

JomGenius “virtuemart” object

Methods

The “virtuemart” object responds to two main public methods: info(), and check().

info() and check() methods for “virtuemart”

The following parameters can be used to get information from the JomGenius “virtuemart” object. This object contains a lot of information about the currently-displayed product and/or category, all of the different page types in VirtueMart, information about the contents of the shopping cart, and about any vouchers that may have been redeemed.

The VirtueMart object is not automatically created for you in MetaMod/MetaTemplate/MetaTemplate Pro. You have to create it yourself, then check to see that it exists before you use it. This is because it won't allow itself to be created if VirtueMart is not installed in Joomla.

Note: There are some "gotchas" about some of these parameters when used by MetaTemplate (as opposed to MetaMod). MetaTemplate (& Pro) work at a very early stage of the generation of a page in Joomla. They operate before VirtueMart itself has had a chance to process the request. Therefore, some parameters such as those requesting the contents of the shopping cart, or whether or not a voucher has been redeemed, will not be updated by VirtueMart in time for these parameters to be calculated by JomGenius.

What happens then, is that JomGenius will appear to "lag" behind the actions of the shopper by one page view. The shopper may redeem a voucher, but on the page that appears directly afterwards, JomGenius will not have detected the voucher. One page later, JomGenius will detect the voucher for the first time.

MetaMod (and any other module using JomGenius) will not have this problem, because the modules get run only after VirtueMart has processed the form input.

Example of creation and usage:

$vm = JomGenius("virtuemart")
if ( $vm ) {
  echo "The VM page type is " . $vm->info("page_type");
}

The following parameters can be used in the VirtueMart "info" and "check" methods:
e.g. $vm->info( "parameter" ) or in $vm->check( "parameter = value")

parameter description type return values
pagetype Contains information about the current page type, but only when it's vm-related string This is the full list of possible results:
  • frontpage, account.billing, account.index, account.order_details, account.orders, account.shipping, account.shipto, checkout.thankyou, shop.browse, shop.ask, shop.cart, shop.infopage, shop.manufacturer, shop.product_details, shop.savedcart, shop.search, shop.waiting_list, shop.waiting_thanks
  • checkout.index#1, checkout.index#2, checkout.index#3, checkout.index#4
product_id The product ID of a product being displayed on a shop.product_details page string 5
category_name The name of the product’s immediate category. If the product is in more than 1 category, this will only return 1 (at random). string Power Tools
category_names The full list (array) of names of the immediate categories that this product is in (particularly if the product is in more than one category). array of strings array("Power Tools", "Outdoor Tools")
category_id The id of the product's immediate category. If the product is in more than 1 category, this will only return 1 (at random). string 2
category_ids The full list (array) of ids for the immediate categories that this product is in (particularly if the product is in more than one category). array of strings array( "2", "4")
number_cart_products Number of different products in the cart integer 5
number_cart_items Number of items in the cart integer 2
is_cart_populated Does the cart have anything in it? boolean true
is_cart_empty Is the cart empty? boolean false
cart_product_ids A list (array) of all product ids for the products in the cart array of strings array( "3","4","37" )
cart_category_ids A list (array) of all the category ids for products in the cart. Note: only one category is given per product, so if a product is in more than one category you can't tell which category you will be given. array of strings array( "2","2","3")
shopper_group The shopper group id. Some of the built-in groups are 5 (default), 6 (gold) and 7 (wholesale). string 5
coupon_code The coupon code, once the shopper has entered it. MY_COUPON
is_coupon_redeemed Has a coupon been redeemed in this session? boolean true
coupon_discount The amount of the discount, whether as a percentage or flat rate. This always returns a number, never with a currency symbol or "%" symbol. string 30
coupon_type Either "gift" or "permanent" depending on what kind of coupon the user entered.
  • gift
  • permanent
Ship To parameters: as a user can have more than one Ship To address, these parameters all return lists (arrays) of information, with one element per address.
shipto_country3s A list of the upper-case 3-letter country codes of the countries in the User’s Ship To addresses. If both addresses are in the same country, then both elements of the array may be the same (and that’s ok). array of strings array( "USA","USA")
shipto_country2s A list of the upper-case 2-letter country codes of the countries in the User’s Ship To addresses. array of strings array( "US", "US" )
shipto_country_names A list of the names of the countries in the User’s Ship To addresses. array of strings array( "United States", "United State" )
shipto_states A list of the states in the User’s Ship To addresses. array of strings array( "CA","CA");
shipto_citys A list of the cities in the User’s Ship To addresses. array of strings array( "Los Angeles", "Los Angeles" );
shipto_zips A list of the zip codes in the User’s Ship To addresses. array of strings array( "90210", "90211" );
shipto_emails A list of the e-mail addresses in the user’s Ship To addresses. array of strings array( " This e-mail address is being protected from spambots. You need JavaScript enabled to view it ", " This e-mail address is being protected from spambots. You need JavaScript enabled to view it ")
Bill To parameters: users can only have 1 Bill To address, therefore each of these parameters returns a simple element.
billto_country3 The upper-case 3-letter country code of the country in the user’s Bill To addresses. string USA
billto_country2 The upper-case 2-letter country code of the country in the user’s Bill To address. string US
billto_country_name The name of the country in the user’s Bill To address. string United States
billto_state The state in the user’s Bill To address. string CA
billto_city The city in the user’s Bill To address. string Los Angeles
billto_email The e-mail address in the user’s Bill To address. string This e-mail address is being protected from spambots. You need JavaScript enabled to view it
The following parameters were introduced on 6 September 2010, in MetaMod 2.5, MetaTemplate 1.6 and MetaTemplate Pro 1.6.
Unless otherwise noted, the following parameters are only relevant when the user is viewing a “product” or product query page.
manufacturer_id The manufacturer id, when on a product page, product query page, manufacturer page or when browsing products by manufacturer integer 1
manufacturer_name The manufacturer name, when on a product page, product query page, manufacturer page or when browsing products by manufacturer string ACME Industries
manufacturer_category_id The manufacturer category id, when on a product page, product query page, manufacturer page or when browsing products by manufacturer integer 2
manufacturer_category_name The manufacturer category name, when on a product page, product query page, manufacturer page or when browsing products by manufacturer string Widget Manufacturers
vendor_id The vendor id integer 3
product_parent_id The product parent id integer 5
product_sku The product SKU string P03
product_short_desc The product short description string Drill through anything.  This drill has the power you need for those demanding hole boring duties.
product_desc The product long description string
 
  • High power motor and double gear reduction for increased durability and improved performance
  • Mid-handle design and two finger trigger for increased balance and comfort
  • Variable speed switch with lock-on button for continuous use
  • Includes: Chuck key & holder

  • Specifications
    4.0 AMPS  
    0-1,350 RPM  
    Capacity: 3/8" Steel, 1" Wood  

    High Power Motor


    lorem ipsum...

    is_product_published true/false for whether or not the product details requested in the URL refer to a published product. boolean true
    product_weight The product weight string 10.0000
    product_weight_unit Units for product_weight string pounds
    product_width The product width string 20.0000
    product_height The product height string 20.0000
    product_length The product length string 20.0000
    product_measurement_unit The measurement unit for width/length/height string inches
    product_in_stock The number of units in stock integer 23
    is_product_special true/false for whether the displayed product is on “special” boolean true
    product_discount_id The product discount id integer 1
    product_ship_code_id The product ship code id integer 0
    product_name The product name string High Power Drill
    product_sales The total number of sales of the product integer 324
    product_attributes The product attributes string Size,XL[+1],M,S[-2];Power,strong,middle,poor[=24]
    product_tax_id The product Tax id integer 1
    product_unit The product’s “Unit” type as specified in the back end. Equal to “download” if it’s a downloadable product. string box
    units_in_box Number of units of this product per box integer 100
    units_in_package Number of units of this product per package integer 16
    child_options (exact use in VM unknown) string N,N,N,N,N,Y,,,
    quantity_options (exact use in VM unknown) string none,0,0,1

     

    Examples:

    $vm = JomGenius("virtuemart"); // initialise object
    if ( $vm->check( "pagetype = frontpage" ) )
            echo "Welcome to the front page of VirtueMart";
     
    if ( $vm->check( "manufacturer_name = ACME Industries" ) )
            return 101; // in MetaMod: use module 101 for all ACME's products
     
    // MetaTemplate rule to show different template products on special
    if ( $vm->check( "is_product_special = true" ) ) return true;
     
    // MetaTemplate rule to use different template when stock is low
    if ( $vm->check( "product_in_stock < 10" ) ) return true;
     
    // MetaTemplate rule to use particular template for products in cats 3-5
    if ( $vm->check( "category_ids = 3,4,5" ) ) return true;
    Last Updated on Monday, 06 September 2010 11:30