Author Topic: Get if custom fields exist  (Read 238 times)

dslove

  • Jr. Member
  • **
  • Posts: 57
Get if custom fields exist
« 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.

Code: [Select]

$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

  • Contributing Developer
  • Sr. Member
  • *
  • Posts: 3248
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Get if custom fields exist
« Reply #1 on: July 23, 2018, 17:38:02 pm »
Your code is a little bad.

Code: [Select]
<?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

  • Jr. Member
  • **
  • Posts: 57
Re: Get if custom fields exist
« Reply #2 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.