News:

Support the VirtueMart project and become a member

Main Menu

Configuration=>Templates and Template Overrides

Started by neo314, May 12, 2013, 22:34:04 PM

Previous topic - Next topic

neo314

Hi All,

I can use Joomla template overrides to make changes, and I understand that the VM settings in Configuration=>Templates for "Select the default template for your Shop" and "Category Template" refer to complete Joomla Template alternatives to the default Joomla Template, but I cannot seem to find any information on what "Category Layout" and "Product Layout" are for or how to use them. There is "No Override", and "Default". Does "Default" refer to default.php and, if so, I still ask how I use this setting?

jenkinhill

Lets assume that you have twio categories that you want to have different layouts for, and you make an override file for category2 and call it cat2.php and install it in your Joomla templates html/com_virtuemart/category/ directory. The on the override list in the category editor you will see that cat2 has been added to the choices. Select this for that cagegory, and leave the other category at no override. Then the cats display differently. Product Details Page works similarly.

See  http://docs.virtuemart.net/tutorials/33-templating-layouts.html and  http://www.ostraining.com/blog/joomla/overrides 
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

neo314

Quote from: jenkinhill on May 12, 2013, 23:51:43 PM
Lets assume that you have twio categories that you want to have different layouts for, and you make an override file for category2 and call it cat2.php and install it in your Joomla templates html/com_virtuemart/category/ directory. The on the override list in the category editor you will see that cat2 has been added to the choices. Select this for that cagegory, and leave the other category at no override. Then the cats display differently. Product Details Page works similarly.

See  http://docs.virtuemart.net/tutorials/33-templating-layouts.html and  http://www.ostraining.com/blog/joomla/overrides

Thanks. That was helpful. I think (correct me if I'm worng) that you should look over the documentation you referenced because it does not cover this.

A Joomla override only overrides a view that exists, and a view often, given the Joomla naming convention affects more files that just the view file.

This method adds new view choices without having to modify any other files (because the same model and view.html.php and controller are used). VM is taking care of pointing to the view that is created outside of VM based on a setting. If I haven't missed something, it seems that this is not addressed in the documentation and may deserve a specific page or section in the documentation.

neo314

#3
This might be a more helpful response as to what I mean.

The documentation page reads:

QuoteThe virtuemart default shop template is overriding the joomla configurations. You can choose in the configuration the template and layout for the shop, the category and the product view and you can override these values per category and product.

The problem behind this construction is that the joomla template override system does only work for the template loaded by joomla. So when you have the "Rhuk_milkyway" template set as default in joomla, but you use for example the "Beez" template for categories and placed a layout for override in it, then it is not used! Because joomla looks only in the "Rhuk_milkyway" template for layouts.

So you can use a lot different templates, but the layouts must be stored in the template which is the default of joomla.

I take that to mean that I can override an existing view like category/default.php but only in the template that the shop is using. Ok, that makes sense, but the override per category or product is not explained and isn't necessarily intuitively understood in context to the Joomla override system.

What if it read:

Quote
The virtuemart default shop template is overriding the Joomla configurations.

You can choose the Joomla template and layout for the shop in the VM configuration under the Templates tab.

The problem behind this construction is that the joomla template override system does only work for the template loaded by joomla. So when you have the "Rhuk_milkyway" template set as default in joomla, but you use for example the "Beez" template for categories and placed a layout for override in it, then it is not used! Because joomla looks only in the "Rhuk_milkyway" template for layouts.

So you can use a lot different templates, but the layouts must be stored in the template which is the default of joomla.

The VM Template system also lets you create additional view templates for categories and products. To override the default categories, category, or productdetails view, simple use the standard Joomla template override method. Copy /components/com_virtuemart/views/[categories, category, or productdetails]/default.php to /templates/[Your Template]/html/[categories, category, or productdetails]/default.php and make your changes to the template version of default.php.

To create additional views that can be set on a per category/product basis, simply copy /templates/[Your Template]/html/[categories, category, or productdetails]/default.php to a new file name like /templates/[Your Template]/html/[categories, category, or productdetails]/mySpecialView.php and make the desired changes. In the Virtuemart category or product configuration, you will find mySpecialView in the drop down list of alternatives views that can be used.

Of course, I could just be missing something in the documentation that makes it obvious. If that is the case, sorry to waste your time.  ::)

mickelodian

Quote from: jenkinhill on May 12, 2013, 23:51:43 PM
Lets assume that you have twio categories that you want to have different layouts for, and you make an override file for category2 and call it cat2.php and install it in your Joomla templates html/com_virtuemart/category/ directory. The on the override list in the category editor you will see that cat2 has been added to the choices. Select this for that cagegory, and leave the other category at no override. Then the cats display differently. Product Details Page works similarly.

See  http://docs.virtuemart.net/tutorials/33-templating-layouts.html and  http://www.ostraining.com/blog/joomla/overrides

I've done all that, and the extra option does indeed appear in the configuration=> templates section of my virtual BE.... however nothing is happening at all in relation to the actaul template. I'm assuming (rightly or wrongly) that this is therefore a joomla issue (presumably) .

Even if I paste something like echo "<h1>BIG FAT TEST</h1>"; into the new override file nothing at ll happens on the front end.

Am I correct in that this template is maybe one of the very few that does not use the template directory as a default for overrides? Or am I, as I suspect doing something truly stupid?

If so since I've spent so long modifying it and its way too late to back out now...can I do something to modify the template to accept the VM override somehow?

jenkinhill

echo "<h1>BIG FAT TEST</h1>";  ???  place outside of a php block - between ?> and <?php and as   <h1>BIG FAT TEST</h1>  for testing purposes.

All VM view tmpl files can be used as overrides when placed in eg [yourjoomlatemplate]/html/com_virtuemart/category/   (if for category layout)  There is one commercial template developer that uses a different directory layout for overrides, but I can't remember who at the moment.

Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum