A weirdly named site with lots of boring content!

Sun 10 Dec 2006

Formating the Category Listing

The category listing is displayed on the VirtueMart 'home page', ie option=com_virtuemart on the URL, but no page or other parameter.

Going into the /templates/soinnovate/index.php file, and uncommenting the call to mosMainBody(), reveals that the content of the page I'm looking at is built by this function.

Searching for function mosMainBody in Windows Explorer locates the code in /includes/frontend.php. I know I've looked at this a few times before, I just can't immediately recall how it does its thing.

The key code is echo $GLOBALS['_MOS_OPTION']['buffer'];. In the admin side, this is populated by the index2.php page. On the public side, there is an index2.php page which does the same thing. It does not appear to be related to the actual code generated though, and the page we're interested in is index.php. Like index2.php, it has code to populate $_MOS_OPTION['buffer'].

It appears to work the same as in admin. Output buffering is enabled, and then the required code is included. The output buffer is then stored in $_MOS_OPTION['buffer'] by capturing the output of ob_get_contents(). We can simply echo the $path variable (which determines the code to include) to find where the page content is generated for any page. Doing this points us towards /components/com_virtuemart/virtuemart.php.

This page gets its content by including the PAGEPATH.$modulename.".".$pagename.".php" file. $modulename and $pagename are obtained by splitting the $page parameter on '.', which seems to be an unnecessary process given they are stuck back together in this way.

Anyway, for the homepage, ie with no parameters other than option, the administrator/components/com_virtuemart/html/shop.index.php file is included.
Leave Comment

/xkcd/ The End of the Rainbow