joomla Archives | Lee Willis https://www.leewillis.co.uk/tag/joomla/ Tue, 11 Jan 2011 07:55:52 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 Adding Virtuemart Product Images to your Sitemap https://www.leewillis.co.uk/virtuemart-product-images-sitemap/ https://www.leewillis.co.uk/virtuemart-product-images-sitemap/#comments Wed, 28 Apr 2010 20:58:28 +0000 http://www.leewillis.co.uk/?p=266 I wrote in a recent post about how to add post images into your sitemap based on WordPress post images. However I look after a couple of sites, and they’re not all WordPress. So I set off on a quest … Continue reading

The post Adding Virtuemart Product Images to your Sitemap appeared first on Lee Willis.

]]>
I wrote in a recent post about how to add post images into your sitemap based on WordPress post images. However I look after a couple of sites, and they’re not all WordPress. So I set off on a quest to add images to sitemaps on my Joomla! sites.

The good news is that my sitemap plugin of choice, Xmap, had recently added basic image support to their XML sitemaps. However, while Xmap can generate sitemaps for a wide variety of Joomla! components – the only one to have image support currently is the standard com_content extension. One of my main Joomla! sites though is a store based on Virtuemart, and I wanted to add product images to the sitemap.

The result is a revised version of the com_virtuemart extension for Xmap, and a small change to the Xmap XML output code.

To get things up and running there’s five simple steps:

  1. Make sure you’re running version 1.2.7 of Xmap
  2. Take backups of all of these files from your existing Joomla! installation:
    • components/com_xmap/xmap.xml.php
    • administrator/components/com_xmap/extensions/com_virtuemart.xml
    • administrator/components/com_xmap/extensions/com_virtuemart.php
  3. Download com_virtuemart.xml and com_virtuemart.php from here, and save them into administrator/components/com_xmap/extensions/
  4. Download xmap.xml.php from the same place, and save it into components/com_xmap/
  5. Configure the com_virtuemart extension under com_xmap settings in your Joomla! administrator area. Make sure you’ve got images turned on, and a license URL specified if you want one.

That’s it – your sitemap should now include images for all of your products.

PS. The default Joomla! robots.txt bans Googlebot from crawling the Virtuemart image folders, you can allow them, by adding:

Allow: /components/com_virtuemart/shop_image/product/

to the bottom of your robots.txt …

The post Adding Virtuemart Product Images to your Sitemap appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/virtuemart-product-images-sitemap/feed/ 11
Joomla / Virtuemart Campaign Monitor Plugin https://www.leewillis.co.uk/joomla-virtuemart-campaign-monitor-plugin/ https://www.leewillis.co.uk/joomla-virtuemart-campaign-monitor-plugin/#comments Wed, 21 Apr 2010 21:22:29 +0000 http://www.leewillis.co.uk/?p=252 I’ve run a Joomla site, and a Campaign Monitor subscriber list for around 18 months. For most of that time I’ve manually exported subscribers from Joomla and imported them to Campaign Monitor. Finally I got fed up, and put together … Continue reading

The post Joomla / Virtuemart Campaign Monitor Plugin appeared first on Lee Willis.

]]>
I’ve run a Joomla site, and a Campaign Monitor subscriber list for around 18 months. For most of that time I’ve manually exported subscribers from Joomla and imported them to Campaign Monitor. Finally I got fed up, and put together a simple Joomla to Campaign Monitor plugin.

The plugin auto-subscribes new users (Whether they register deliberately, or are created by other plugins – e.g. by purchasing from a Virtuemart store) to your chosen Campaign Monitor list.

To get up and running, follow these 4 simple steps:

  • Download the plugin
  • Install it
  • Set up your Campaign Monitor details in the configuration screen

    You can find a great guide for finding these IDs here
  • Activate the plugin

Obviously, you’ll want to make sure that you have the user’s permission to contact them as part of the registration policy.

Happy integrating.

The post Joomla / Virtuemart Campaign Monitor Plugin appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/joomla-virtuemart-campaign-monitor-plugin/feed/ 21
How to write an application for WordPress https://www.leewillis.co.uk/writing-a-wordpress-application/ https://www.leewillis.co.uk/writing-a-wordpress-application/#comments Mon, 07 Sep 2009 21:36:12 +0000 http://www.leewillis.co.uk/?p=132 I’ve recently been doing some work for a family member on a WordPress blog they run, and the need came up to build a mini-app. Now historically, I’m a Joomla kind of guy, and it’s fairly clear that for a … Continue reading

The post How to write an application for WordPress appeared first on Lee Willis.

]]>
I’ve recently been doing some work for a family member on a WordPress blog they run, and the need came up to build a mini-app. Now historically, I’m a Joomla kind of guy, and it’s fairly clear that for a Joomla site you would build a component to implement your app.

However, in WordPress it’s a little different. I’ve found loads of articles about available API calls, manipulating “the loop” and all sorts of useful information. What I haven’t found though is something that explains at a fundamental level how I should approach the problem.

There isn’t a concept of an “application” under WordPress, the only items that are accessible are “posts” and “pages”. As far as I can tell, I have two options:

  1. Publish a post/page with no content other than a special string (E.g. [my-app]) and then write a plugin that filters post content and replaces the magic string with the output from the application
  2. Create a page, and assign it a custom template. Implement your application in that custom template

Option 1

It works, I know because this is what I did 🙂   However there is a performance penalty, your application code is called on every post, and so you have to take steps to make sure it doesn’t run unnecessarily. The other disadvantage is that well, it just doesn’t seem clean.

Option 2

This seems a little nicer, but doesn’t really fit with WordPress’ nice plugin installation architecture – as far as I can tell plugins can’t auto-install into the current theme directory, and custom templates can’t live anywhere else.

So, this leaves me a little confused – can anyone point me as to how I should have solved this problem – or does WordPress need to grow up a little and add “application” alongside posts and pages?

The post How to write an application for WordPress appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/writing-a-wordpress-application/feed/ 3
Gzip in Joomla – Tips for a faster website https://www.leewillis.co.uk/gzip-joomla-tips-faster-website/ https://www.leewillis.co.uk/gzip-joomla-tips-faster-website/#comments Wed, 13 May 2009 09:30:04 +0000 http://www.leewillis.co.uk/?p=75 The average internet connection is much more capable of delivering sizeable web content today than it was even 12 months ago – the UK average broadband connection at time of writing is 4.6Mb/s. The problem It’s important to remember that: … Continue reading

The post Gzip in Joomla – Tips for a faster website appeared first on Lee Willis.

]]>
The average internet connection is much more capable of delivering sizeable web content today than it was even 12 months ago – the UK average broadband connection at time of writing is 4.6Mb/s.

The problem

It’s important to remember that:

  1. Not everyone has broadband
  2. Most web browsers don’t take advantage of the bandwidth available

GZIP Compression

If you’re developing a site in Joomla for example you often hear people suggesting “turn on compression” within Joomla. This option compresses the page content created by Joomla before sending it back to the browser in real-time.

While this is a great solution for some sites, there are significant issues with this approach for many sites. It’s important to realise that the HTML page is only 1 of the many requests needed to generate a webpage – you also need all of the images, CSS files, and JS.

Take for example a typical template from YOOtheme – a major Joomla theme provider. The actual HTML for March 2009 theme demo is 1 out of 31 requests, and just 7kB out of a total of 144 kB.

It’s worth noting that if the objective is to make your site “faster” then Joomla’s gzip may not be the best option. The downsides to this approach are:

  • It only affects the size of the HTML page
  • It does that by compressing the content on-fly
    • Cacheing aside – this can result in you compressing the file every time it is requested – adding a significant processor load to your server
    • The process of compressing the data adds a delay (However small) before your content can be sent
  • It does nothing about the other files that make up the webpage
  • It doesn’t maximise your bandwidth usage by minimising total number of requests

My Approach

For the sites that I run I use the following approach:

  • Identify files that are included widely, but updated infrequently
  • Consolidate multiple files into one (ie, create just one .js file for your site, and one .css file)
  • Create a compressed version of these files alongside the original
  • Use a bit of .htaccess magic to serve the compressed files to everyone who can deal with them.

This is a good solution for files which don’t change frequently (CSS, template images, JS includes etc.) This approach gives you the best of both worlds, compressed files, but low server CPU impact.

The HOWTO

To implement it simply create a compressed copy of the file(s) you want to compress. If you have shell access to your website files you can do:

$ gzip -9 -c foo.js > foo.jsgz

This should leave you with your original uncompressed file, and a compressed variant with the suffix “gz”.

Now add the following to your .htaccess file:

#Check to see if browser can accept gzip files.
ReWriteCond %{HTTP:accept-encoding} (gzip.*)
#make sure there’s no trailing .gz on the url
ReWriteCond %{REQUEST_FILENAME} !^.+gz$
#check to see if a .gz version of the file exists.
RewriteCond %{REQUEST_FILENAME}gz -f
#All conditions met so add .gz to URL filename (invisibly)
RewriteRule ^(.+) $1gz [L]
AddType “text/css;charset=UTF-8” .cssgz
AddEncoding gzip .cssgz
AddType “text/javascript;charset=UTF-8” .jsgz
AddEncoding gzip .jsgz

Remember if you do change any of the uncompressed versions you’ll have to re-generate the compressed version otherwise clients that support gzip won’t see the changes.

There are some complications when using Joomla with Virtuemart (Since it insists on loading CSS/JS support files itself) – but that’s a topic for another day!

When we implemented this on SnugBaby it reduced the total number of files required from over 35 to 27, and the total download size from over 200k to 144k – would love to hear other’s experiences.

The post Gzip in Joomla – Tips for a faster website appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/gzip-joomla-tips-faster-website/feed/ 9
Featured Products With Virtuemart https://www.leewillis.co.uk/featured-products-virtuemart/ https://www.leewillis.co.uk/featured-products-virtuemart/#comments Wed, 06 May 2009 21:09:35 +0000 http://www.leewillis.co.uk/?p=61 Featured Products e-Commerce stores often want to highlight a particular product or products. This can because they have new products to promote, special offers, stock to clear – or just because they believe it will help conversion. While the popular … Continue reading

The post Featured Products With Virtuemart appeared first on Lee Willis.

]]>
Featured Products

e-Commerce stores often want to highlight a particular product or products. This can because they have new products to promote, special offers, stock to clear – or just because they believe it will help conversion.

While the popular Virtuemart e-commerce system will let you mark products as “On Special”, it doesn’t offer an out-of-the box way to highlight these special products on the main shop pages.

This article will show you how you can use this “On Special” functionality to implement “featured products” in your product listing pages on your Virtuemart Site – take a look at the example below:

Featured Baby Carriers

Standard Functionality

The standard Virtuemart functionality allows you to set a product as “On Special” – as the image below shows.
Setting the On Special Flag
Unfortunately, this information about your products isn’t available to your theme, so you can’t style your products differently, nor can you sort them to the top of your list (As most designs would require).

Getting the information

The first thing we need to do is make sure that the details about whether the flag is set or not is pulled back from the database. The file we’re interested in is shop_browse_queries.php which is in administrator/components/com_virtuemart/html/.

Line 39 specifies a variable called $field_names, so we need to add the database field product_special to this list, e.g.

shop_browse_queries.php – Line 39:
$fieldnames = "`product_name`, `products_per_row` , `category_browsepage` ,
`category_flypage` , `#__{vm}_category`.`category_id` ,
`#__{vm}_product`.`product_id` , `product_full_image` , `product_thumb_image` ,
`product_s_desc` , `product_parent_id` , `product_publish` ,
`product_in_stock` , `product_sku` , `product_url` ,
`product_weight` , `product_weight_uom` , `product_length` ,
`product_width` , `product_height` , `product_lwh_uom` ,
`product_in_stock` , `product_available_date` ,
`product_availability` , `product_special`,
`#__{vm}_product`.`mdate` ,  `#__{vm}_product`.`cdate`";

We then need to make sure that this information is added to the product array available to the layout code.

shop.browse.php – Line 450:
$products[$i]['product_special'] = $db_browse->f("product_special");

Now, in your browse page template, you can simply check the value of $product_special, and change your HTML output accordingly. For example, on SnugBaby, we wrap featured products in a styled div:

<?php if ($product_special == 'Y') : ?> <div class="featuredheading"> <h3>Featured Product</h3> </div> <div class="featured"> <?php endif; ?>

Bubbling up…

So far we’ve managed to highlight featured products, and the next change is a bit take it or leave it. However, when we were doing our implementation of this on SnugBaby we decided that it looked considerably better if the featured products were first in the list. So, the following change makes special products jump up to the top of your list, with the rest of the product according to your standard ordering rules:

shop.browse.php – Line 450:
$q .= "\n ORDER BY product_special desc, $orderbyField $DescOrderBy";

If you want to see the final result, check out the SnugBaby Baby Carrier pages.

The post Featured Products With Virtuemart appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/featured-products-virtuemart/feed/ 7
Virtuemart Category Discounts https://www.leewillis.co.uk/virtuemart-category-discounts/ https://www.leewillis.co.uk/virtuemart-category-discounts/#comments Thu, 30 Apr 2009 08:30:23 +0000 http://www.leewillis.co.uk/?p=38 Background Virtuemart is an excellent Open Source e-Commerce system that integrates with the Joomla content management system. I use it on a number of sites – some with more challenging eCommerce requirements than others. While Virtuemart offers bulk purchase discounts … Continue reading

The post Virtuemart Category Discounts appeared first on Lee Willis.

]]>
Background

Virtuemart is an excellent Open Source e-Commerce system that integrates with the Joomla content management system. I use it on a number of sites – some with more challenging eCommerce requirements than others.

While Virtuemart offers bulk purchase discounts (£10 each, or 3 or £27 style offers) – it unfortunately only implements these on a per-product basis. This is great if you want to order 3 of the exact same pair of baby shoes.

However, a common request is to implement category-based discounts, so  for example you would be able to offer a discount where people buy multiple products from a particular category.

We do just this on SnugBaby, where we periodically run category based discounts on our baby shoes, where the requirement is that you get a discount if you choose to buy multiple products from a particular category.

Caveats

There are some caveats to the approach we’re going to describe below:

  1. It involves patching the Virtuemart source files  – this is not a Plugin, Component, or module. You should attempt this only if you’re comfortable editing PHP code
  2. Further to the above – if you upgrade Virtuemart this will need re-applying, possibly with some tweaks and tickles
  3. This assumes you’re running Virtuemart 1.1.3 (Although the theory of the approach works with VM 1.0.x as well)

Summary

This approach uses the Virtuemart bulk pricing model to store the bulk prices. This means you need to go through the products that are on special offer and add in the bulk prices. In the example I’m going to use here we are selling baby shoes. The standard price is £16.50 per pair, but if you buy more than 1 pair (Of any design), then you get them for £15.00 per pair.

We market this as “2 for £30” – however the reality (Probably should be caveat number 4!) is that it becomes £15 per pair for any number of shoes 2 and over (E.g. you could get 3 pairs for £45, 4 pairs for £60 and so on …).

So. First things first. Add the pricing to Virtuemart. If you’ve never done bulk pricing in Virtuemart here’s a quick guide. For each of your products in turn, edit the product, and choose “List Prices”:

listprices

Then you’ll need to specify your pricing:

productprices

Once this is done then your customers can get the special price, but only if they buy 2 or more of the same product.

The fun part

We can make all the changes we need to in just one file, administrator/components/com_virtuemart/classes/ps_product.php. This file is responsible for calculating product pricing, taking into account quantity discounts. The function in question is get_price().

This function out-of-the-box is given a product ID and is asked to calculate the price. It has a section relating to quantity pricing which roughly follows the following logic:

– Cycle through all cart contents

– If the product_id of the cart item matches the product_id we’re trying to cost then sum up the quantity of this item

– Retrieve the product price based on total volume of a product in the cart

We’re going to amend the second step such that it sums up the quantities of all products in the same category as the product we’re trying to cost.

The full patch (For the impatient) is here.

The patch is split into 2 main sections. The first gets the category that the product we’re costing belongs to (Caveat #5 – I have no idea what happens if your bulk purchase products are in multiple categories!). It also checks if that category is eligible for bulk discounts. You’ll need to change the 28 below to match your category ID.

Line 1608:
// Get the product_parent_id for this product/item
$product_parent_id = $this->get_field($product_id, “product_parent_id”);
// LW PATCH – Get the category of this product – used later to drive category-based multiple purchases
$sesq = “SELECT category_id FROM #__{vm}_product_category_xref WHERE product_id=’$product_id'”;
$db->setQuery($sesq); $db->query();
$db->next_record();
$sesprodcat = $db->f(“category_id”);
if ($sesprodcat == 28) {
$ses_cat_discount = TRUE;
} else {
$ses_cat_discount = FALSE;
}
// END LW PATCH

The next section changes the calculation so that instead of comparing the product IDs, we comapre category IDs:

Line 1622:
// LW PATCH – If any product in the cart is in the same category then treat as volume purchase
if ($ses_cat_discount) {
  $sesq = “SELECT category_id FROM #__{vm}_product_category_xref WHERE product_id='”.$cart[$i][“product_id”].”‘”;
  $db->setQuery($sesq); $db->query();
  $db->next_record();
  $sesprodchildcat = $db->f(“category_id”);
  if ($sesprodchildcat == $sesprodcat) {
    $quantity += $cart[$i][“quantity”];
  }
} else {

  if ($cart[$i][“product_id”] == $product_id) {
    if ($parent) {
      $parent_id = $cart[$i][“parent_id”];
Line 1631:
       }
     }
   }
}
// END LW PATCH

And that’s that. Give it a try, let me know what you think!

The post Virtuemart Category Discounts appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/virtuemart-category-discounts/feed/ 61