Quick templating tutorial for Reverse Auction Factory 1.0

Reverese Auction Factory includes a very powerful templating engine - smarty. We will try to cover in this tutorial the essentials of building a template for Reverse Auction Factory using this Template Engine. By far this can not cover the extensive manual of smarty. Making use of smarty, the auction engine will provide to this engine some pre-filled objects and arrays of objects that are relevant to the current page displayed. Also all language constants defined in Reverse Auction Factory can be accessed in the template. We advice against writing hard coded text into the Templates, since this would render the multi language concept useless. If you do not care about the ability to translate your site, then you can do as needed.

This tutorial is addressed to the HTML savvy webmaster that need to change the default appearance of Joomla's Reverse Auction Factory Component. For most customers the default template should be sufficient accommodating.

First of all what is a template engine. A (web) template engine is software that is designed to process web templates and content information to produce output web documents. It runs in the context of a template system. It is practically a php script that interprets some kind of pseudo HTML pages containing placeholders for specific variable content. In our case most are auction related.

In order to update much easier, we recommend that you note all the changes made on the templates, then apply them on each update in order to avoid any issues!

1. Where are the files and what can be changed?

All template files are in the components/com_rbids/templates folder. The components/com_rbids/templates/cache folder contains the pre-processed files and normally you should not have to edit or delete something in it. We recommend that this folder has writing rights for PHP scripts, so the engine can improve the speed by caching the templates.

t_auctiondetails.tpl Contains the template for displaying the Auction Item details page
t_categories.tpl Display of Categories page (Category Directory)
t_editauction.tpl is used to display the page for "New Auction" and "Edit Auction". The $task smarty variable contains the current task (newauction or editauction)
t_header_filter.tpl Displays a message div with the current active filters
t_javascript_language.tpl Javascript birdge for language strings. Should not be modified in most cases and should be included in most templates
t_listauctions.tpl The base template for auction listing. Here are the listing elements being rendered. Most of the output is done in the corresponding *_cell.tpl
t_listauctions_cell.tpl The Auction listing cell. this is the cell for one auction. The cycling is done in t_listauctions.tpl
t_listfooter.tpl Listing footer (pagination links).
t_myauctions.tpl similar to listauctions, only for "My auctions"
t_myauctions_cell.tpl similar to listauctions_cell, only for "My auctions"
t_mybids.tpl similar to listauctions, only for "My Bids"
t_mybids_cell.tpl similar to listauctions_cell, only for "My Bids"
t_mywatchlist.tpl similar to listauctions, only for "My watchlist"
t_mywatchlist_cell.tpl similar to listauctions_cell, only for "My watchlist"
t_mywonbids.tpl similar to listauctions, only for "My won bids"
t_mywonbids_cell.tpl similar to listauctions_cell, only for "My won bids"
t_overlib.tpl JS for overlib. Should be included if overlib is used
t_payment_cancel.tpl Returning page from Paypal if the payment was canceled
t_payment_return.tpl Returning page from Paypal on successful payment (can be overridden in the payment plugin)
t_search.tpl Template for the search page
t_showSearchResults.tpl Template for the Search Results
Template for the user search page
Template for the user Search Results
Template for reporting an Auction form

2. Basic smarty knowledge.

All smarty templates are pure HTML. What the template engine needs to interpret must be put in accolades { }, a so called smarty tag. If the smarty contains a variable or a constant, then smarty just replaces it with its value. for instance this tag {$task} will be replaced with the current joomla task (for instance with "newauctions" - without the quotation marks).

Smarty also allows IF clauses, so you an branch out two different displays depending on a condition. So for example {if $task=='newauctions'}You are creating a new auctions{else}You are editing an existing auction{/if} will display one of the two texts depending on the current task. Another useful smarty command is {include file='xxxxx'} - this includes another smarty template file. For instance it it useful for us in the matter of including the necessary javascript for the auctions. Since most pages use the same javascript codebase we can have just a single page containing these statements. For assigning a value to a variable (if the variable does not exist, it will be created) you have to use {assign var=variablename value='VALUE'} in this way you may use smarty for advanced templating techniques that resembles more with programming.

3. Custom defined smarty functions for AUCTIONS FACTORY.

Since Smarty is a very powerful tool for templating, we can create custom functions that can be called out from templates. Functions that are not in the standard distribution of smarty. We created following functions that can be used especially for our purpose (Auctions).

  • {set_css} - prints out the Auction CSS
  • {infobullet text="some info text"} - creates a standard joomla help bullet (requires overlib to be initalized first)
  • {printdate date=$some_date_variable use_hour=0} - prints out the date variable according to the datetime format chosen in admin backend (use_hour=0 - ignores hours, use_hour=1 prints also the time)
  • {createtab} - initalizes the Tabbed output (joomla standard)
  • {startpane id="content-pane" usecookies=0} - starts the Tabbed pane (the container that holds all tab pages). the usecookies setting can be set to 1, leading to the tabbed display to remember what particular tab was last time active when you visited that page
  • {endpane} - ends a previously started tabbed pane
  • {starttab paneid="content-pane" text="Tab caption"} - Starts a new TAB in the pane with the id "content-pane" (you must use the id from the startpane call)
  • {endtab} - Ends a TAB

4. Variables that are ALWAYS initialized by the auction system.

  • {$mosConfig_live_site} - the url of the site. as defined in Joomla Configuration
  • {$Itemid} - The menu Itemid
  • {$task} - the current task
  • {$option} - the current option (should always be com_bids)
  • {$is_logged_in} - true if the user is logged in. false if not
  • {$userid} - the joomla user id. if not logged in it will be null or 0
  • {$new_auction_link} -new auction link is availble in every page

All Language constants and configuration constants are accessible in the template; all are in the form {$smarty.const.xxxx} where xxxx is the constant name. For instance for the constant string defined as "bid_auction_number" you have to use {$smarty.const.bid_auction_number}. All saved options are the following:

  • bid_opt_max_picture_size - max image size in kb
  • bid_opt_date_format - Date format string (PHP style)
  • bid_opt_date_time_format - Hour format string (PHP style)
  • bid_opt_thumb_width - Thumbnail width
  • bid_opt_thumb_height - Thumbnail height
  • bid_opt_medium_width - Auction Detail page image width
  • bid_opt_medium_height - Auction Detail page image height
  • bid_opt_availability - max months that an auction can last
  • bid_opt_maxnr_images - max nr of images allowed for an auction
  • bid_opt_allow_messages - True if messages are allowed between auctioneer and bidder
  • bid_opt_archive - max moths that auctions are kept in the database
  • bid_opt_nr_items_per_page - pagination
  • bid_opt_enable_hour - enable hour for auctions (if false then auctions expire on midnight)
  • bid_opt_enable_countdown - enables the countdown in auctions listings
  • bid_opt_language - language file
  • bid_opt_enable_acl - true if the site uses ACL (Access Class lists ) - Bidder and Seller group
  • bid_opt_acl_type - Acl type - groups or field
  • bid_opt_acl_bidder - Bidder group
  • bid_opt_acl_seller - Seller Group
  • bid_opt_allow_paypal - allow users to specify their paypal email in order to facilitate the funds transfer
  • bid_opt_hide_contact - hides user contact data if set up
  • bid_opt_allow_messenger - requires / shows messengers ids if set up
  • bid_opt_disable_images - enables images uploads (i.e. display) for auctions
  • bid_opt_nda_compulsory - forces user to sign a NDA when bidding

5. Auction Variables initialized in specific pages.

5.1. Variables initialized in Auction Details and Auction listings.

For auction detail the main object is called $auction, in auction listings the cell templates will hold a similar object called $current_row The properties of $auction and $current_row are similar. We will present them for $current_row. If you need them in Auction details or in Auction Edit/New you must replace "$current_row" with "$auction"  

  • $current_row->id // The auction ID - Needed for specific calls
  • $current_row->userid // The Auctioneer USER-ID (Joomla native)
  • $current_row->title // The Auction TITLE
  • $current_row->shortdescription // The Auction Short description
  • $current_row->description //The Auction Description
  • $current_row->picture // The auction MAIN picture name (not the URL!)
  • $current_row->link_extern //The external link (Settable by the auctioneer)
  • $current_row->initial_price // The Auction inital price - as an float. for formatting use {$auction->initial_price|string_format:"%.2f"}
  • $current_row->currency // The Currency ID (Not the currency name!)
  • $current_row->currency_name // Currency Name (Ex. USD)
  • $current_row->start_date //Start date of the Auction in a datetime type (not formatted)
  • $auction->start_date_text //Start date of the Auction in a datetime type (formatted)
  • $current_row->end_date //End date of the Auction in a datetime type (Not formatted)
  • $auction->start_date_text //End date of the Auction in a datetime type (formatted)
  • $current_row->closed_date //Closing date of the Auction. To format use {printdate date=$auction->closed_date}
  • $current_row->published // True if published. Just for MY Auctions
  • $current_row->close_offer // True if Auction is closed
  • $current_row->close_by_admin //True if Auction is BANNED - just for MY Auctions
  • $current_row->hits // Nr of hits
  • $current_row->modified // Last edit time - not formatted, use printdate
  • $current_row->newmessages// True if New messages are available for the current looged user in this auction
  • $current_row->winner_id // Winner userid.
  • $current_row->i_am_winner // true if the current logged user is winner in this auction
  • $current_row->cat // Category id (NOT category name)
  • $current_row->catname // Category Name (Ex. Automobiles)
  • $current_row->auction_nr // AUN (Auction Unique Number)
  • $current_row->username //auctioneer Username
  • $current_row->verified_auctioneer //True if auctioneer is verified
  • $current_row->rating_auctioneer // Rating as a seller for the auctioneer
  • $current_row->rating_bidder // Rating as a bidder for the auctioneer
  • $current_row->rating_overall // Overall auctioneer rating
  • $current_row->auctioneer // object containing the auctioneer joomla user info
  • $current_row->auctioneer_details // object containing Reverse Auction Factory relevant Auctioneer User info (city, country,..)
  • $current_row->rownr // Current number (for cells only)
  • $current_row->nr_new_messages // Nr of new messages in this auctions message board for the current user
  • $current_row->is_my_auction // True if the current logged user is also the auctioneer of the auction
  • $current_row->del_from_watchlist //true if current auction IS in the users watchlist
  • $current_row->add_to_watchlist //true if current auction IS NOT in the users watchlist
  • $current_row->mybid //My latest bid to the auction
  • $current_row->nr_bidders //Nr of bidders for the current auction
  • $current_row->winning_bid //amount of the winning bid (for auctions that have a winner)
  • $current_row->highest_bid //Current highest bid for the auction
  • $current_row->countdown //if show countdown is enabled contains the current countdown text (Ex: "2 days,2 hrs,10 min,2secs")
  • $current_row->expired // True if the auction is expired (the end date is passed)
  • $current_row->thumbnail //countains the thumbnails html code.
  • $current_row->links.otherauctions // contains the url to "Other auctions by this auctioneer"
  • $current_row->links.bids // Contains the link to the current bids of the auction
  • $current_row->links.edit // Contains the link to "Edit this auction"- just for my auctions
  • $current_row->links.cancel //Contains the link to "Cancel this auction"- just for my auctions
  • $current_row->links.publish //Contains the link to "Publish this auction"- just for my auctions
  • $current_row->links.republish //Contains the link to "Republish this auction"- just for my auctions
  • $current_row->links.filter_cat //Contains the link to the category filter for the auctions category
  • $current_row->links.messages //Contains the link to the message list for the current auction
  • $current_row->links.add_to_watchlist //Contains the link that adds the current auction to the users watchlist
  • $current_row->links.del_from_watchlist //Contains the link that removes the current auction to the users watchlist
  • $current_row->links.auctioneer_profile // contains the link to the auctioneer profile
5.2. Variables for search template.
  • {$lists.cats} - category pick up list HTML code
  • {$lists.country} - country pick up list HTML code
  • {$lists.city} - city pick up list HTML code
  • {$lists.users} - Users pick up list HTML code
5.3. Variables for Auction details.
  • {$auctioneer} - contains the object that defines the Joomla user
  • {$auctioneer_details} - contains the object that defines the Auctioneer details (city, country, verified..)
  • {$bid_list} - the list of placed bids on this auction
  • {$message_list} - list of messages to the current user
  • {$terms_and_conditions} - true if there are terms and conditions to accept

6. Final advices and considerations.

Before starting to work on the templates take a look at the provided ones, and try to understand how they are done. Leave all hidden inputs as they are. If unsure better ask in our forums. Remove the inputs from the template only if sure what you do. you can put them where you like on the page, but if you what to remove one better ask.

Test if your changes generate JS errors. These could alter the behavior of the pages.

There are virtually no security issues in changing the templates. The data that should not appear is also not initialized (lets say for a private auction). But caution is always a good approach, so test first what kind of auction or what kind of rights are currently active.

MOST IMPORTANT OF ALL: do not hesitate to search and to ask! The forums are a great place to share information.

This Tutorial is compliant with Reverse Auction Factory 1.0