Global Smarty Variables used in Prestashop

Today i want to share a useful list of smarty global variables. All of this variables you can use in template files (both modules and theme). Enjoy!

 

{$base_dir_ssl} URL of your store when SSL certificate is active
{$base_dir} URL of your store
{$cart} Information about cart. Read entries below for more informations
{$cart->id} ID of customer cart
{$cart->id_shop_group} ID of shop group (multistore feature)
{$cart->id_shop} ID of shop (multistore feature)
{$cart->id_address_delivery} ID of customer address delivery (only if order was made)
{$cart->id_address_invoice} ID of customer address invoice (only if order was made)
{$cart->id_currency} ID of cart currency
{$cart->id_customer} ID of customer for which cart belongs (only if customer is logged)
{$cart->id_guest} ID of shop guest
{$cart->id_lang} ID of cart language
{$cart->recycable} Bool value if recycable checked for this cart
{$cart->gift} Bool value if gift checed for this cart
{$cart->gift_message} Gift message
{$cart->mobile_theme} Bool value if cart was created on mobile device
{$cart->date_add} Date of cart creation
{$cart->date_upd} Date of cart update
{$cart->id_carrier} Id of cart carrier (if selected)
{$cart->checkedTos} Bool value if terms of service is checked
{$img_cat_dir} URL for the directory with categories images
{$img_ps_dir} URL for the directory with PrestaShop image
{$img_lang_dir} URL for the directory with languages images
{$img_sup_dir} URL for the directory with suppliers images
{$img_ship_dir} URL for the directory with carriers images
{$img_prod_dir} URL for the directory with products images
{$img_manu_dir} URL for the directory with manufacturers images
{$img_dir} URL for the directory with theme’s images
{$css_dir} URL for the directory with theme’s CSS
{$modules_dir} URL for the directory with modules
{$mail_dir} URL for the directory with mail templates
{$js_dir} URL for the directory with theme’s JavaScript
{$tpl_dir} URL for the directory with current theme’s
{$pic_dir} URL for the directory with uploaded pictures
{$lang_iso} ISO code for the current language
{$cart_qties} Number of products in the cart
{$come_from} URL for the visitor’s origin
{$shop_name} Shop name
{$currency} Currency object (currently used currency).
{$currencies} The various available currencies
{$id_currency_cookie} ID of the current currency
{$cookie} User cookie
{$languages} The various available languages
{$priceDisplay} Price display method (with or without taxes…)
{$roundMode} Rounding method in use
{$logged} Indicates whether the visitor is logged to a customer account
{$page_name} Page name
{$customerName} Client name (if logged in)
{$use_taxes} Indicates whether taxes are enabled or not
[Total: 1    Average: 5/5]

How to create a widget area in wordpress theme

How to enable widget area in wordpress theme

Custom widget area is enabled from function.php that is available in the themes folder.
Add the following code in function.php to enable/register widget area in the wordpress theme:

How to add widget area in wordpress theme

Once you have enabled the function in function.php you can make any area as a widget area within a wordpress theme. Add the following code to the area ( sidebar, footer, header ) where you want the widget to to make a slot and add widget to it later from widgets setting panel:

NOTE: If you want more then one area to be widgetized at the same time, then you have to register sidebar in function.php more then once with different names and id’s

Now that you have enabled the widget area as well as created a slot for the widgets to be placed in, you can go to Appearance -> Widgets in admin panel and add the widgets to the slot you have just created.

[Total: 1    Average: 5/5]

Show Siblings or Children of a WordPress Page

It’s useful for making pages’ sub menu in wordpress.

[Total: 2    Average: 3.5/5]

How to use do_shortcode() in wordpress

Function Reference/do shortcode

Description

Searches content for shortcodes and filters shortcodes through their hooks.

Usage

Parameters

$content
(string) (required) Content to search for shortcodes
Default: None

Return Values

(string)
Content with shortcodes replaced by the output from the shortcode’s handler(s).

Examples

[Total: 1    Average: 5/5]

Useful WordPress Functions

WordPress “Cron Jobs”

Schedules a hook which will be executed by the WordPress actions core on a specific interval, specified by you. The action will trigger when someone visits your WordPress site, if the scheduled time has passed.

So if you want to execute some code on a regular base, like checking an RSS Feed, doing a database backup or reseting database values this function will do it for you. Unfortunatley its not as easy to use as transient but here is a short article on how it is done:
http://themocracy.com/2010/02/wp-cron-automating-scheduling/
http://codex.wordpress.org/Function_Reference/wp_schedule_event

Easily Fetch an RSS Feed with WordPress

fetch_feed is another simple wordpress method to get feed content. It also has the added benefit that it uses the SimplePie and FeedCache functionality for retrieval and parsing and automatic caching.

http://codex.wordpress.org/Function_Reference/fetch_feed

WordPress mail function

An incredible useful and exceptional easy to use function that also allows you to send headers and attachments, allows plain text sending and html messages and quite a few other options!

http://codex.wordpress.org/Function_Reference/wp_mail

WordPress Shortcode API

add_shortcode() is an easy way to create macros for your post content. for example lets say you want to wrap some content inside the post area within a div with some additional classes and ids that allows you to create multiple columns. you could of course just switch to the html editor and enter

Easier and more convenient especially if you are dealing with customers who dont know html would be a shortcode solution within your functions.php file:

You could then use this shortcode in your post content:

If you would like to nest shortcodes within each other you would need to make sure to add the do_shortcode method to your function like this:

http://codex.wordpress.org/Shortcode_API

Create WordPress post with a php function:

This function inserts posts pages and custom post types in the database. It sanitizes variables, does some checks, fills in missing variables like date/time, etc. very handy when you need to create and insert posts by user input. This function fits perfectly if you have a front end form for example and users can suggest posts.

http://codex.wordpress.org/Function_Reference/wp_insert_post

[Total: 1    Average: 5/5]

Free Business Hosting, IP Transit & RAM Sale

Servers Australia are offering free web hosting for life, to all Australian businesses. Go to their Facebook Free Web Hosting Page, ‘Like us’ then signup to receive your free web hosting. Please note this is available for businesses only and a limit of one per customer applies. Offer ends on 29/02/2012.

They are also having a $40 per Mbit on all IP Transit Services Sale. This service can be used for Dedicated Servers, Co-location or directly by interconnecting at one of their POP’s in Global Switch, Equinix SY1, Equinix SY2, Equinix SY3 or the Servers Australia DC. Available to new customers for 12 month (minimum) signups, available till 13/03/12.

They are also offering triple RAM on i3 server and E3-1225, Double RAM on E3-1245 Server. See their dedicated servers page here for a breakdown on the server details. Offer ends 29/02/12.

Details on all their current special offers are available on Servers Australia Special Offers page here.

[Total: 1    Average: 5/5]

Multilingual SEO, Things to Remember

Google has recently done a series on the usability of multilingual websites and it got me thinking about multilingual SEO. How do you, in fact, optimize the same website for keywords in multiple languages?

But let’s start with the core basics. In simple terms, a multilingual website is a website that has content in more than one language. And such website has a lot of on-page stuff that is often done wrong. Let’s take a look at some common issues:

1) Language recognition

Once Google’s crawler lands on your multilingual website, it starts with determining the main language on every page. Google can recognize a page as being in more than one language but you can avoid crawler confusion by doing the following:

  • Stick to only one language per page
  • Avoid side-by-side translations
  • Use the same language for all elements of the page: headers, sidebars, menus, etc.

Some web editors create code-level attributes automatically but these attributes are not very reliable, so keep in mind that Google ignores all code-level information (from “lang” attributes to DTD (Document Type Definitions) during language recognition.

2) URL structure

A typical pet peeve of SEO but even more so with multilingual websites. To make the most of your URLs, consider language-specific extensions. Language-specific extensions are often used on multilingual websites to help users (and crawlers) identify the sections of the website they are on and the language the page is in. For example:

http://www.website.ca/en/content.html

http://www.en.website.ca/content.html

http://www.website.ca/fr/content.html

http://www.fr.website.ca/content.html

This is a great way to organize URLs on a multilingual website because not only does it help the user, but it also makes it easier for the crawler to analyze the indexing of your content. But what if you want to create URLs with characters other than English? Here’s how to do it right:

  • Use UTF-8 encoding for non-English characters
  • Make sure your UTF-8 encoded URLs are properly escaped when linked from within your content

i.e. if a URL contains an é, which is a non-English character: http://www.website.ca/fr/contént.html

here’s how it will look properly escaped: http://www.website.ca/fr/cont%C3%A9nt.html

It is important to note that Google directly extracts character encodings from HTTP headers, HTML page headers, and content. There isn’t much you need to do about character encoding, other than watching out for conflicting information – for example, between content and headers. While Google can recognize different character encodings, use UTF-8 on your website whenever possible.

3) Crawling and Indexing

Another common area of focus for SEO. On multilingual websites, follow these recommendations to get more pages crawled:

  • Avoid redirects based on user’s perceived language: they could, in fact, prevent both users and SEs from looking at more pages on your site.
  • Keep the content for each language on separate URLs
  • Don’t use cookies to show translated page versions
  • Cross-link page by page

Last but not least, please remember that Google does not recommend automatic translations.

By getting the on-page basics right, you will set a great base for your multilingual SEO in the future and, unlike so many others, you will not have to beg (in multiple languages) SE crawlers to come and index your content.

[Total: 1    Average: 5/5]