
What this book covers
We will explain the basic structure of the VirtueMart themes and templates and go into the detail of all important templates. We will also show you how to customize the templates and add new features to your theme with lots of real-world exercises. The customization is not just on HTML elements and CSS styles. Many of them involve changing the PHP and JavaScript code, adding new features and behaviors. We even included exercises that demonstrate how to integrate Joomla! plugins, JavaScript frameworks, existing JavaScript code, and Joomla! components into VirtueMart themes and templates.
We understand your customization projects will have many diverse varieties. So we've tried to include examples of different types, templates, and module pages as much as possible within the limitation of the text. Yet there may be areas we cannot touch on in the exercises or areas we didn't go into as much details as you would have liked. In that case, you can refer to the comprehensive template reference in Appendix, VirtueMart Template Reference, where we have covered all 86 templates in seven different template groups (up to version 1.1.5).
VirtueMart is one of the most complex components in Joomla!. It is impossible to cover every area of VirtueMart in a little book like this. The main subject of this book is VirtueMart themes and templates. Themes and templates are those parts of VirtueMart responsible for the final presentation of data to the browser. In particular, most of the templates, if not all, only deal with the frontend. While we will explain the VirtueMart engine in some detail and touch on other areas, our focus will remain on themes and templates. That means we will not touch on the many details of classes and module pages, except when they are related directly to the themes and templates. That also means we will not discuss customization of the backend VirtueMart modules. Creation or customization of payment modules and shipping modules are not part of the presentation engine and so they will not be discussed in this book. Also, we will not talk about the VirtueMart database structure.
If you are seeking help solely for a VirtueMart backend project or for payment and shipping module, this book is not for you. You can treat this book as a first step in knowing how VirtueMart works, though. After you thoroughly grasped the idea presented here, you will definitely have a solid foundation in researching ways to hack into the backend.
To be successful in your customization project, you will probably need to tweak some PHP code or include some JavaScript handlers. However, this book is not a textbook on programming and so will not tell you all the bells and whistles of writing PHP or JavaScript programs. We will give you a basic idea of how to tweak code but do not expect that you will become a seasoned programmer after reading this book.
While we will touch on simple techniques on tweaking Joomla! to work in our way, this book will not tell you the detailed structure of Joomla!. In some exercises, we may step into Joomla! technicalities such as customizing a Joomla! module. However, Joomla! is not the focus of this book and so you may need to refer to other textbooks on Joomla! if you want to work further on the modules.
Chapter 1, The Virtuemart Engine, will briefly review the Joomla!/VirtueMart file structure. We will then continue to explain the presentation framework of Joomla! and VirtueMart. A high-level view of the VirtueMart engine will be presented and we will see how the VirtueMart theme and template fits in the whole system. After that, we will be able to understand the various ways to customize the VirtueMart shop and provide a list of items we need to consider before heading on a customization project.
Chapter 2, The VirtueMart Default Theme, will focus on the default theme and its accompanied template structure. We will start with the shopping life cycle in VirtueMart, the backbone of the theme and template system. We will then give a general description of the VirtueMart configuration settings with a closer look at the Site configurations that relate closely to the frontend presentation. After that, we will concentrate on exploring the default
theme. We will see the options that are available in the default
theme configuration. Finally, we will give a brief introduction to the seven template groups under the default
theme and understand their basic usage.
Chapter 3, Product List Templates, is the first of four chapters that explains the working of major template groups. In this chapter, our focus is on the the product list templates. We will start with a sample template to see how a template works. Some basic PHP language constructs will be introduced before looking at the browse page elements and then the three different product list styles. We will look closely at each of the major templates in the group. We will guide you to customize the basic layout, the header, the navigation links, the add-to-cart form, the product list styles, and many more.
Chapter 4, Product Details Templates, will build upon what we have introduced in the previous chapter but shift the focus to the product details templates. We will look at the major elements that compose a product details page and then the templates that are related to each of those elements. We will look at how to customize the flypage, header, product images and files, product review, add-to-cart form, advanced attribute and custom attribute, and many more.
Chapter 5, Changing the Look of VirtueMart, will further our understanding of the template system by looking at peripheral stuff that is not inside a template file but are affecting the look of the site. We will look at the stylesheet, the JavaScript, the URL links, and the language element. Then we will continue our investigation in the template system by studying a few more templates that may not be considered as the core but will definitely affect the impression of the shop. Examples to customize the CSS, JavaScript, language element, manufacturer page, vendor page, ask seller form, and the VirtueMart home page are explained.
Chapter 6, From Shop Basket to Final Checkout, will walk through the latter half of the shopping life cycle, from the time that a product is added to the shop basket to the time that the customer finishes with the order. We will first explain how the shop basket data is stored in the server and look at the various elements on the shop cart page. A major part of these discussions will focus around the shop basket templates. Next, we will cross the border to the checkout templates and follow every page in the checkout process. For each of the checkout steps, there are associated templates. We will look at each of the templates and see how they can be customized to fit our needs. While working with the exercises, we will introduce further techniques that can be employed to customize VirtueMart without hacking into the core files.
Chapter 7, VirtueMart Templates and Joomla! Modules, will look at the customization of the various Joomla! modules that come with VirtueMart. We will also touch on the templates for some peripheral elements on a flypage: recent products, related products, and so on.
Chapter 8, VirtueMart Theme Anatomy, will look at the detailed structure of a VirtueMart theme. We will first look at the VirtueMart theme class and see how the whole theme system works. Then we will focus on each of the components: the images, the JavaScript, the CSS file, the theme file, and theme configuration. Finally, we will try to see how we can add new configurations to the theme configurator by hacking into the files.
Chapter 9, Theme Customizations, will look at the details of customizing or creating a VirtueMart theme. We will first see the differences between customizing and creating a theme. Then we will discuss the pros and cons of creating a new theme rather than customizing the default
theme. We will then proceed to considering the various issues that we need to consider before creating a new theme. After that, we will demonstrate how to integrate JavaScript Utilities and Joomla! plugin to a VirtueMart theme. Finally, we will take a brief look at how to use custom VirtueMart classes to provide our own logics in VirtueMart.
Chapter 10, Additional Customization Possibilities, will look at some advanced customization possibilities for modifying the templates and theme. Most of the materials are practical stuff and each section may not be that related to the rest of the chapter. The only common thing among them may be they are all interesting customization examples. We will talk about breaking complex templates into smaller manageable ones. We will talk about sharing templates between two template groups. We will work on using images to display advanced attributes. We will use the product type template to include a file uploader. Finally, we will touch on some more exercises using custom VirtueMart class file to make various changes to the price system.
In Appendix, VirtueMart Template Reference, we provide a comprehensive reference for all the templates of the default
theme, listing out the purpose and usage of the template, its parent and child parents, related page and class files. The most important part is the available fields, where you will find the fields that you can use in a template and also a brief explanation of what the field is for.
Note
This appendix is not present in the book but is available as a free download from http://www.packtpub.com/sites/default/files/downloads/Appendix.pdf.