News:

Looking for documentation? Take a look on our wiki

Main Menu

Get if custom fields exist

Started by dslove, July 23, 2018, 14:40:41 PM

Previous topic - Next topic

dslove

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?

Studio 42

#1
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.

dslove

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.