VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: dslove on July 23, 2018, 14:40:41 PM

Title: Get if custom fields exist
Post by: dslove on July 23, 2018, 14:40:41 PM
Hi all,

I'm building a custom Joomla template for a VM shop, but I would like to have the following checks:

1) If page viewed is category page

2) If the products in this category have any custom fields assigned or not.

I already have code in place to check if current component is virtuemart and it works fine.



$jinput = JFactory::getApplication()->input->get('option');

<?php if ($jinput == 'com_virtuemart') : ?>
<?php endif; ?>



Is it even possible to get all of the above info in the template's index.php file?
Title: Re: Get if custom fields exist
Post by: Studio 42 on July 23, 2018, 17:38:02 PM
Your code is a little bad.

<?php $input JFactory::getApplication()->input;
$component $input->get('option');
$view$input->get('view');
if(
$component == 'com_virtuemart' && $view === 'category') {
  
// check for product having id 124
 
$pid =  $inpput->getInt('virtuemart_product_id');
  if(
$pid ==='124) {
  //mu code for product 124
  }
}
?>

But another solution is to use 2 layout if this is in the cmponent view and use this layout for such specific cases.
Title: Re: Get if custom fields exist
Post by: dslove on July 30, 2018, 17:58:08 PM
Thank you so much for your help, and sorry it took so long to reply.
Website owner requested that we go a completely different way, so I won't be needing to do this.

Again, thank you for your help, it is much appreciated.