You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Idea for categories per row modification

Started by Piszi, December 16, 2015, 23:19:49 PM

Previous topic - Next topic



I was working on a new design/template for a VM 3 based webshop and the design required an always centered arangement for the categories. So I was thinking how can I do it, how can I make it fail safe because I'm not managing the site and the administrator isn't a genius :) and always forgets to set categories or products properly. On this site the basic arrangement for categories is set 4/row but if they add a new category with less lets say only 2 subcategories VM will add class width25 but it should be width50.
So I made a little code modification in the sublayout categories and set the width calculation like this:

$count_categories = count($categories);
if($categories_per_row > $count_categories){
  $category_cellwidth = ' width'.floor(100/$category_count);
  $category_cellwidth = ' width'.floor(100/$categories_per_row);

This way if the number of categories are less than the defined number in the config/category config the width always will be set correclty.
The modification would be more efficient if you could somehow decide that the categories/row number($categories_per_row) is coming from the main VM setting or from the individual category setting, because this way you could still have a custom setting option if its needed and than set a condition to check where the c/r is coming from.
Something like this:

$categories_per_row_custom = VmConfig::get ( 'categories_per_row_custom' );
  $categories_per_row = $categories_per_row_custom;
  $categories_per_row = VmConfig::get ( 'categories_per_row', 3 );

and than the code I wrote before
Or maybe there could be an option in VM settings like automatic categories / row and than it would make the template code a little simplier.

But as the topics title shows this is only an idea.
And I'm curious what the dev team and others on the forum think about this.