M
M
Maxim2015-03-25 15:07:50
Joomla
Maxim, 2015-03-25 15:07:50

How to add an additional parameter to the Joomla mod_virtuemart_manufacturer module?

Hello. Joomla has a standard mod_virtuemart_manufacturer module that is responsible for displaying manufacturers. But this module has one drawback - it cannot edit the number of manufacturers that I would like to display.
What I have already done:
1. Added variables to the mod_virtuemart_manufacturer.xml file

<param name="manufacturers_per_line" type="text" default=""
            label="MOD_VIRTUEMART_MANUFACTURER_LINE"
            description="MOD_VIRTUEMART_MANUFACTURER_LINE_DESC" />

2. Added variables to the mod_virtuemart_manufacturer.php file
$manufacturers_per_line = $params->get( 'manufacturers_per_line', 5); // Display 5 manufactureres in Line

3. Variables declared in localizations
Now we need to fix the code so that it displays only the amount that we specify in the admin panel for this variable:
<ul class="vmmanufacturer<?php echo $params->get('moduleclass_sfx'); ?>">
<?php
foreach ($manufacturers as $manufacturer) {
  $link = JROUTE::_('index.php?option=com_virtuemart&view=manufacturer&virtuemart_manufacturer_id=' . $manufacturer->virtuemart_manufacturer_id);
  ?>
  <li><a href="<?php echo $link; ?>">
    <?php
    if ($manufacturer->images && ($show == 'image' or $show == 'all' )) { ?>
      <?php echo $manufacturer->images[0]->displayMediaThumb('',false);?>
    <?php
    }
    if ($show == 'text' or $show == 'all' ) { ?>
     <div><?php echo $manufacturer->mf_name; ?></div>
    <?php
    }
    ?>
    </a>
  </li>
  <?php
  if ($col == $manufacturers_per_row && $manufacturers_per_row && $last) {
    echo '</ul><ul class="vmmanufacturer'.$params->get('moduleclass_sfx').'">';
    $col= 1 ;
  } else {
    $col++;
  }
  $last--;
} ?>
</ul>

thanks for the help

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2015-03-25
@maximtop

It seems he figured it out.
Should have added a break at the end of the foreach

if ($manufacturers_per_line <= 0) {
    break;
  } else {
    $manufacturers_per_line--;
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question