News:

Support the VirtueMart project and become a member

Main Menu

Custom fields in specific product layout position in category page

Started by haidamaka, May 25, 2012, 22:35:54 PM

Previous topic - Next topic

haidamaka

Hello!
I'm trying to show custom fields(specific product layout position) with in category page. (I  read many topics, but I didnt find the solution). I think there are people who have solved this problem.
So Im using such code:

               <?php if (!empty($product->customfieldsSorted['sale'])) { ?>
   <div class="sale">
   <?php
   $custom_title = null ;
   foreach ($product->customfieldsSorted['sale'] as $field){
      if ($field->display) {
         ?>
         <?php if ($field->custom_title != $custom_title) { ?>
                       <?php if ($field->custom_tip) echo JHTML::tooltip($field->custom_tip,  JText::_($field->custom_title), 'tooltip.png');
         } ?>
        <?php echo $field->display ?>
       
                  <?php
         $custom_title = $field->custom_title;
      }
   } ?>
   </div>
<?php } // Product Custom ontop end ?>


Virtuemart:2.0.6;Joomla:2.5.4.
Pleaese help!

stuart.prevos

Can you show the custom fields at all, or is it just that you want them in a specific order on the category page.

I have same problem I want to show the custom fields on the category page.

haidamaka

I  read here that its possible only with custom coding. But nobody cant tell what coding I need.
But to make custom fields work easy  just copy code from any product and replace $this-> like here http://forum.virtuemart.net/index.php?topic=100696.0

stuart.prevos

Eventually got around to figuring this out

foreach ($product->customfields as $field)
               
                {
                  echo $field->custom_title;
                  echo $field->display;
                  }                }

Funky

This thread really saved me a lot of headache. I was working on the same thing and this place solved my problem. Great job dude. thx
I want to help. If you need help PM me :)

programador.5

Quote from: stuart.prevos on September 06, 2012, 15:21:51 PM
Eventually got around to figuring this out

foreach ($product->customfields as $field)
               
                {
                  echo $field->custom_title;
                  echo $field->display;
                  }                }

I just wanted to say thank you for that very useful piece of code.

If you want to sort the custom fields by position, you just need to add this: if( $field->layout_pos=='myposition'), so it looks like this:

foreach ($product->customfields as $field){
if( $field->layout_pos=='showcat'){
echo "<strong>".$field->custom_title."</strong><br>";
echo $field->display."<br>";
}
}


Hope this might help a little bit.

Cheers!

AH

Is there a better way we ask ourselves??  Please let us know! Milbo.
Regards
A

Joomla 4.4.5
php 8.1