VirtueMart Forum

VirtueMart 2 + 3 + 4 => General Questions => Topic started by: marvays on June 08, 2023, 06:57:19 AM

Title: meta tag to category pages
Post by: marvays on June 08, 2023, 06:57:19 AM
Hello.
Because of the SEO tool, I need to recognize category pages in the page code. Ideally, you would add a meta tag that only appears on the category page, for example:
<meta property="og:type" content="Category" />

I wanted to add this tag to:
/templates/hera_j3_vm3/html/com_virtuemart/category/default.php
But my poor php knowledge won't allow it.
Could you help me?


<?php
/**
 *
 * Show the products in a category
 *
 * @package    VirtueMart
 * @subpackage
 * @author RolandD
 * @author Max Milbers
 * @todo add pagination
 * @link http://www.virtuemart.net
 * @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
 * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 * VirtueMart is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * @version $Id: default.php 8508 2014-10-22 18:57:14Z Milbo $
 */
defined ('_JEXEC') or die('Restricted access');
$app JFactory::getApplication('site');
$tname $app->getTemplate('template')->template;
$template $app->getTemplate(true);
$listgrid $template->params->get('listgrid');

if (!
class_exists('CurrencyDisplay'))
require(VMPATH_ADMIN DS 'helpers' DS 'currencydisplay.php');
$currency CurrencyDisplay::getInstance( );

$category_id  vRequest::getInt ('virtuemart_category_id'0);
$manufacturer_id  vRequest::getInt ('virtuemart_manufacturer_id'0);

//JHtml::_ ('behavior.modal');
//id taken in the view.html.php could be modified
if (vRequest::getInt('dynamic',false) and vRequest::getInt('virtuemart_product_id',false)) {
if (!empty($this->products)) {
if($this->fallback){
$p $this->products;
$this->products = array();
$this->products[0] = $p;
vmdebug('Refallback');
}

echo shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));

}

return ;
}
?>

<div class="category-view">
<?php
$js 
="
jQuery(document).ready(function ($) {
  var orderlistcontainer = $('div.orderlistcontainer');
  var activeOrder = $('div.activeOrder');
  activeOrder.click(function(){
    $(this).toggleClass('arrow-up').siblings('div.orderlist').toggle();
  });
  activeOrder.find('a').click(function(event){
    event.stopPropagation();
  });
  orderlistcontainer.mouseleave(function(){
    $(this).find('div.orderlist').hide();
    if (activeOrder.hasClass('arrow-up')) {
      activeOrder.removeClass('arrow-up');
    }
  });
});
"
;

//vmJsApi::addJScript('vm-hover',$js);

if (!empty($this->category->category_name))
{
  echo 
'<h1 class="vt-cat-h">'.vmText::_($this->category->category_name).'</h1>';
}

if (
$this->show_store_desc and !empty($this->vendor->vendor_store_desc)) { ?>

<div class="vendor-store-desc jumbotron">
<?php echo $this->vendor->vendor_store_desc?>
</div>
<?php }

if (!empty(
$this->showcategory_desc) and empty($this->keyword)) {
if(!empty($this->category->category_description)) { ?>

    <div class="vt-cat-desc clearfix">
    <?php echo $this->category->category_description?>
    </div>
<?php
}

if(!empty(
$this->manu_descr)) { ?>

<div class="manufacturer-description vt-cat-desc clearfix">
<?php echo $this->manu_descr?>
</div>
<?php }
}
// Show child categories
if ($this->showcategory and empty($this->keyword) and $manufacturer_id == 0) {
if (!empty($this->category->haschildren)) {
echo ShopFunctionsF::renderVmSubLayout('categories',array('categories'=>$this->category->children'categories_per_row'=>$this->categories_per_row));
}
}

?>

<?php echo '{{module 204}}' ?>
<?php
if (!empty($this->products) or ($this->showsearch or $this->keyword !== false)) {
?>

<div class="browse-view match-height">

  <?php if ($this->showsearch or $this->keyword !== false) : // BEGIN Search Box?>
<h3><?php echo $this->keyword?></h3>
<div class="virtuemart_search">
<form action="<?php echo JRoute::('index.php?option=com_virtuemart&view=category&limitstart=0'FALSE); ?>" method="get">
<?php if(!empty($this->searchCustomList)) { ?>
<div class="vm-search-custom-list">
<?php echo $this->searchCustomList ?>
</div>
<?php ?>

<?php if(!empty($this->searchCustomValuesAr)) { ?>
<div class="vm-search-custom-values">
<?php
        
echo ShopFunctionsF::renderVmSubLayoutAsGrid(
            
'searchcustomvalues',
            array (
                
'searchcustomvalues' => $this->searchCustomValuesAr,
                
'options' => array (
                    
'items_per_row' => array (
                        
'xs' => 2,
                        
'sm' => 2,
                        
'md' => 2,
                        
'lg' => 2,
                        
'xl' => 2,
                    ),
                ),
            )
        );
        
?>

</div>
<?php ?>
<div class="vm-search-custom-search-input input-group">
<input name="keyword" class="inputbox form-control" type="text" size="40" value="<?php echo $this->keyword ?>"/>
        <span class="input-group-btn">
  <input type="submit" value="<?php echo vmText::('COM_VIRTUEMART_SEARCH'?>" class="button btn" onclick="this.form.keyword.focus();"/>
        </span>
  <?php //echo VmHtml::checkbox ('searchAllCats', (int)$this->searchAllCats, 1, 0, 'class="changeSendForm"'); ?>
</div>
      <div class="vm-search-descr alert alert-info margin-top"> <?php echo vmText::_('COM_VM_SEARCH_DESC'?></div>
<!-- input type="hidden" name="showsearch" value="true"/ -->
<input type="hidden" name="view" value="category"/>
<input type="hidden" name="option" value="com_virtuemart"/>
<input type="hidden" name="virtuemart_category_id" value="<?php echo $category_id?>"/>
<input type="hidden" name="Itemid" value="<?php echo $this->Itemid?>"/>
</form>
</div>

  <?php
  $j 
'jQuery(document).ready(function() {
    jQuery(".changeSendForm")
     .off("change",Virtuemart.sendCurrForm)
      .on("change",Virtuemart.sendCurrForm);
  })'
;
  
vmJsApi::addJScript('sendFormChange',$j);
  
?>

  <?php endif; // End Search Box ?>

  <?php if (!empty($this->products) && !empty($this->orderByList)) : // Orderby-displaynumber ?>
  <div class="orderby-displaynumber clearfix">
    <div class="width70 floatleft">
      <?php if ($listgrid) : ?>
      <div id="listgrid" class="btn-group hidden-xs" role="group" style="vertical-align: bottom;margin-right:15px">
        <button type="button" class="btn btn-list"><i class="fa fa-th-list" aria-hidden="true"></i></button>
        <button type="button" class="btn"><i class="fa fa-th" aria-hidden="true"></i></button>
      </div>
      <?php endif; ?>
      <div class="orderlistcontainer">
      <div class="title"><?php echo vmText::_('COM_VIRTUEMART_ORDERBY'); ?></div>
      <div id="vm-orderby" class="hidden"><?php echo $this->orderByList['orderby']; ?></div>
  <?php
      $orderBy 
strip_tags($this->orderByList['orderby'],'<a><script>');
      
$orderBy explode('</a>',$orderBy);
      
$orderBy str_replace(['<a','</a','-/+','+/-','href'vmText::_('COM_VIRTUEMART_ORDERBY')], ['<option','</option','','','value',''], $orderBy);
      
?>

      <select onchange="window.location.href=this.value">
      <?php foreach ($orderBy as $option) : ?>
      <?php echo $option ?>
      <?php endforeach; ?>
      </select>
      <button id="orderDir" class="btn btn-default" type="button" onclick="window.location.href=jQuery('#vm-orderby').find('.activeOrder').children('a').attr('href');" style="vertical-align:bottom;"><span class="fa fa-sort"></span></button>
      </div>
     
    </div>
    <div class="width30 floatright display-number">
      <?php echo $this->vmPagination->getResultsCounter ();?>
      <br/>
      <?php echo $this->vmPagination->getLimitBox ($this->category->limit_list_step); ?>
    </div>
    <div class="vm-pagination clearfix">
      <?php echo str_replace('<ul>''<ul class="pagination">'$this->vmPagination->getPagesLinks ()); ?>
      <span class="floatleft"><?php echo $this->vmPagination->getPagesCounter (); ?></span>
    </div>
  </div>
  <?php endif; // End of orderby-displaynumber ?>

  <?php if (!empty($this->products)) : ?>

    <?php //revert of the fallback in the view.html.php, will be removed vm3.2
    
if($this->fallback){
    
$p $this->products;
    
$this->products = array();
    
$this->products[0] = $p;
    
vmdebug('Refallback');
    }
    echo 
shopFunctionsF::renderVmSubLayout($this->productsLayout,array('products'=>$this->products,'currency'=>$this->currency,'products_per_row'=>$this->perRow,'showRating'=>$this->showRating));
    
?>


    <?php if (!empty($this->orderByList)) : // Show footer pagination?>
    <div class="vm-pagination vm-pagination-bottom">
      <?php echo str_replace('<ul>''<ul class="pagination">'$this->vmPagination->getPagesLinks ()); ?>
      <span class="vm-page-counter"><?php echo $this->vmPagination->getPagesCounter (); ?></span>
    </div>
    <?php endif; ?>

  <?php elseif ($this->keyword !== false) : ?>

    <?php echo '<p class="alert alert-info margin-top">' . vmText::_ ('COM_VIRTUEMART_NO_RESULT') . ($this->keyword ? ' : (' . $this->keyword . ')' : '') . '</p>'; ?>

  <?php endif; ?>

</div>

<?php ?>
<script>
jQuery('div.main-box').removeClass('main-box');
</script>
</div>
<?php
if(VmConfig::get ('ajax_category'false)){
$j "Virtuemart.container = jQuery('.category-view');
Virtuemart.containerSelector = '.category-view';"
;

vmJsApi::addJScript('ajax_category',$j);
vmJsApi::jDynUpdate();
}
?>

<!-- end browse-view -->
Title: Re: meta tag to category pages
Post by: Ghost on June 08, 2023, 08:37:40 AM
$this->document->setMetaData('og:type', 'Category', 'property');
Title: Re: meta tag to category pages
Post by: pinochico on June 09, 2023, 18:47:23 PM
hmm
plugin phoca meta tags not helped?
For us yes
Title: Re: meta tag to category pages
Post by: Jumbo! on June 12, 2023, 17:08:08 PM
You can use VM OG Meta Tag plugin on your site, which adds these meta tags automatically. It is a free plugin - https://www.virtueplanet.com/extensions/vm-og-meta-tag