News:

Support the VirtueMart project and become a member

Main Menu

Category Page Fields for Templating

Started by PRO, February 08, 2012, 19:42:18 PM

Previous topic - Next topic

PRO

These fields are for use in the category view
For product page fields, look here http://forum.virtuemart.net/index.php?topic=92756

Product fields that are not listed here can be used like this
<?php echo $product->COLUMN_NAME ?>

The difference between category and product page is $this
$this->product      is for product page
$product->   is for product fields on the category page.

SO, to add weight to the category page. You can do
<?php echo $product->product_weight ?>

Category Name
<?php echo $this->category->category_name; ?>

Category Description
<?php echo $this->category->category_description ; ?>

Product Name with Link
<?php echo JHTML::link($product->link, $product->product_name) ?>

Product Details Link with anchor "Product Details"
<?php echo JHTML::link($product->link, JText::_('COM_VIRTUEMART_PRODUCT_DETAILS'), array('title' => $product->product_name,'class' =>
'product-details'));?>

Order by list
<?php echo $this->orderByList['orderby']; ?>

Manufacturer Dropdown
<?php echo $this->orderByList['manufacturer']; ?>

Pages/Links/Pagination
<?php echo $this->vmPagination->getResultsCounter();?>
<?php echo $this->vmPagination->getLimitBox(); ?>
<?php echo $this->vmPagination->getPagesLinks(); ?>
<?php echo $this->vmPagination->getPagesCounter(); ?>

Short Description
<?php echo shopFunctionsF::limitStringByWord($product->product_s_desc, 40, '...') ?>

^^ Notice the 40 above. limitStringByWord strips the text to 40 characters. You can change the "40"
For full short desc
<?php echo $product->product_s_desc ?>

POP UP Product Image
<?php echo $product->images[0]->displayMediaThumb('class="browseProductImage" border="0" title="'.$product->product_name.'"
',true,'class="modal"'); ?>

Link Image to product page
   <?php echo JHTML::_('link', JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product->virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id),$product->images[0]->displayMediaThumb('class="catImage" border="0"',false));
                  ?>

Stock Level
<?php echo $product->stock->stock_level ?>

# Products in Stock
<?php echo $product->product_in_stock ?>

balai


Lexiboy

To display the product weight in a usable format:

// custom code to display weight 
     if ($product->product_weight <> '0'){
     echo "Упаковка: ";
     echo $product->product_weight;
     // echo $product->product_weight_uom;
     if ($product->product_weight_uom == "LB") echo 'мл.';
     if ($product->product_weight_uom == "OZ") echo 'л.';
     if ($product->product_weight_uom == "GR") echo 'гр.';
     if ($product->product_weight_uom == "KG") echo 'Кг.';
     if ($product->product_weight_uom == "MG") echo 'мг.';
     // print_r($product);
     }

Of course I could have dug a bit deeper into the source to find build in functionality to display the labels. To find more options, print_r is your friend :)
With kind regards,
Alex Stienstra

itsystem

Hi,

I would like to display product_sku but when I use <?php echo $this->product->product_sku ?> it dosn't work.
What's the appropriate format ?

Thanks a lot

itsystem

Well, I use :

<?php // Product Sku
echo JHTML::link JRoute::'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id=' $product->virtuemart_product_id '&virtuemart_category_id=' $product->virtuemart_category_id ), $product->product_sku, array ('title' => $product->product_sku ) ); ?>

PRO

Quote from: itsystem on February 17, 2012, 11:36:52 AM
Hi,

I would like to display product_sku but when I use <?php echo $this->product->product_sku ?> it dosn't work.
What's the appropriate format ?

Thanks a lot


$this->   Refers to the current object. So $this-> ON THE CATEGORY page is calling category variables

$product->

coxi

Hi,
At first, thanks a lot for the support. I could make hack and my website is fine.
But...
It would be better if number of item could be shown in category.

Like this :
Category1 (3)           Category2 (17)            Category3 (4)
instead of
Category1                Category2                    Category3

Unfortunatly, i didn't find the solution. Any idea ?
Regards from France. Alain

dontflinch

#7
I'm trying to test for a category image before echoing its link.

I've tried:

<?php if(!empty($this->category->images)) { ?>
       <div id=""><img src="<?php echo $this->category->images[0]->file_url_thumb?>"  alt="" /></div>
<?php }  ?>


but the test does not work (image renders fine if there is one), any ideas anyone?


=========================================================
solution edit: this works (thanks banquet tables pro!):

http://forum.virtuemart.net/index.php?topic=97744.msg326572#msg326572

PRO

Quote from: dontflinch on March 02, 2012, 01:08:16 AM
I'm trying to test for a category image before echoing its link.

I've tried:

<?php if(!empty($this->category->images)) { ?>
       <div id=""><img src="<?php echo $this->category->images[0]->file_url_thumb?>"  alt="" /></div>
<?php }  ?>


but the test does not work (image renders fine if there is one), any ideas anyone?

have you tried?

category->images[0]

dontflinch

I have tried many variations of $this and $category with and without the [0]


trying this makes the image disappear even on pages where there is one:

<?php if(!empty($category->images[0])) { ?>
<div id=""><img src="<?php echo $this->category->images[0]->file_url_thumb?>" alt="" /></div>
<?php ?>



btw I think you are the one I saw first say to use this  echo $this->category->images[0]->file_url_thumb; and I modeled my 'if not empty' on your snippet for the product additional images, thanks.


PRO

<?php if($this->category->images[0]->file_url_thumb) { ?>
       <div id=""><img src="<?php echo $this->category->images[0]->file_url_thumb; ?>"  alt="" /></div>
<?php }  ?>

amanda mc donald

THANK YOU!!!!!

This helped me so much!

Another question.... can you help me with adding new fields to products information page (I do NOT want to add attributes ... I want to add extra fields).
Joomla 1.7 Vm 2

Thank you

amanda mc donald

Hi

I want to use this code (linking image to a product):

<?php echo JHTML::_('link', JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product-
>virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id),$product->images[0]->displayMediaThumb
('class="browseProductImage" border="0"',false)); ?>


BUT instead of linking the image to a product ... I want to link the image to a URL ... how do I do that?

Thank you
amanda

dontflinch

what sort of url (i.e. dynamic or one/static)? I think you'll have to be more specific than this.

Quote from: amanda mc donald on March 10, 2012, 13:17:38 PM
Hi

I want to use this code (linking image to a product):

<?php echo JHTML::_('link', JRoute::_('index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='.$product-
>virtuemart_product_id.'&virtuemart_category_id='.$product->virtuemart_category_id),$product->images[0]->displayMediaThumb
('class="browseProductImage" border="0"',false)); ?>


BUT instead of linking the image to a product ... I want to link the image to a URL ... how do I do that?

Thank you
amanda

amanda mc donald


I want to link an image to a URL on the internet (e.g. a specific youtube video)