Author Topic: Category Page Fields for Templating  (Read 179131 times)

PaulJUK

  • Beginner
  • *
  • Posts: 3
Re: Category Page Fields for Templating
« Reply #60 on: July 17, 2012, 22:49:20 pm »
Hi, looking for some guidance on getting the category name of the product within the category view.

I have used <?php echo $product->category_name; ?> but this returns the main category level not the child category that the product is inside.
I would like to show the name of the child category inside the set of products.
I have tried many variations of this to try and get the required information.

any thoughts?


Any suggestions for this one yet?

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
Re: Category Page Fields for Templating
« Reply #61 on: July 18, 2012, 18:05:21 pm »
Hi, looking for some guidance on getting the category name of the product within the category view.

I have used <?php echo $product->category_name; ?> but this returns the main category level not the child category that the product is inside.
I would like to show the name of the child category inside the set of products.
I have tried many variations of this to try and get the required information.

any thoughts?


Any suggestions for this one yet?

you are not going to be able to do this without writing some code to query the database.


Or, you could use a separate field.
You could use internal notes

<?php echo $product->intnotes ?>

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

robboh69

  • Beginner
  • *
  • Posts: 19
Re: Category Page Fields for Templating
« Reply #62 on: July 25, 2012, 00:25:08 am »
Hi.

Some how would it be possible to iterate and show the categories (like in the categories view) on the category view?
And how would you do that?

the $this-trick will not do that from what I can figure out?  :)

perlarenee

  • Beginner
  • *
  • Posts: 25
Re: Category Page Fields for Templating
« Reply #63 on: July 27, 2012, 17:18:09 pm »
arg, i've seen this question at least 5 or 6 times in various places here and so far no answer cuz the thread keeps going to different topics.

yes i already know that precious rules. But I'am in Module Manufacturer List View that comes with this url attached (index.php?option=com_virtuemart&view=manufacturer&Itemid=131)

and with the link in One Manufacturer Brand (id 2) ( index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=2 )

is different that comming from the normal Product Categories the url ( index.php?option=com_virtuemart&view=category&virtuemart_category_id=2 )
............................
In that Manufacturer (ID 2) Category (or Categories View i dont know the difference because i think this is working bad) the page doesnt show to me the Header Title of Manufacturer too... only displays this in html: <h1></h1> .. no title Name of Manufacturer!! :|

guidocx842

  • Jr. Member
  • **
  • Posts: 74
Re: Category Page Fields for Templating
« Reply #64 on: August 02, 2012, 14:15:40 pm »
Hi everybody!
I need your help to change my category style. What I need is very simple (.. I suppose)
I have many menu voices that are setted to show VM - Single Category. For example, I choose Garden Tools category, from example data.

Now I need to see my category page in this way:

Only the name of the product at the top of the product image, i.e. 300x200 px (image centered). I will set three product for each row.
The image have to be a link to the product page (i.e. http://mysite.it/products/space-treatment/nutrition/ladder-detail) and not to the image file (http://mysite.it/images/stories/virtuemart/product/resized/ladder_90x90.jpg)... not popup...

Can somebody help me please? I find something in /components/com_virtuemart/views/category/tmpl/default.php

I think that I've to modify from // Show Products section (row 439 of the original default.php file)... but I don't know how.

THANKS A LOT!

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
Re: Category Page Fields for Templating
« Reply #65 on: August 02, 2012, 18:02:07 pm »
Hi everybody!
I need your help to change my category style. What I need is very simple (.. I suppose)
I have many menu voices that are setted to show VM - Single Category. For example, I choose Garden Tools category, from example data.

Now I need to see my category page in this way:

Only the name of the product at the top of the product image, i.e. 300x200 px (image centered). I will set three product for each row.
The image have to be a link to the product page (i.e. http://mysite.it/products/space-treatment/nutrition/ladder-detail) and not to the image file (http://mysite.it/images/stories/virtuemart/product/resized/ladder_90x90.jpg)... not popup...

Can somebody help me please? I find something in /components/com_virtuemart/views/category/tmpl/default.php

I think that I've to modify from // Show Products section (row 439 of the original default.php file)... but I don't know how.

THANKS A LOT!


guidocx842,


So you want

NAME
IMAGE



and NOTHING else?   Y Nada?

J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

guidocx842

  • Jr. Member
  • **
  • Posts: 74
Re: Category Page Fields for Templating
« Reply #66 on: August 02, 2012, 19:45:03 pm »
Yes! Nada de nada  :D
My category view will be composed by many rows. On each row three image of the products with at top the name of the products. When the user click on the image he can go to the product specific page where he will find all informations: prices, description, etc.
Is it possible? Many thanks four your help! I really appreciate!

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
Re: Category Page Fields for Templating
« Reply #67 on: August 02, 2012, 20:21:46 pm »


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="browseProductImage" border="0"',false)); ?>

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

Code below is the  category/tmpl/default.php

It displayes

IMAGE
Product-Name

Code: [Select]
<?php
/**
*
* Show the products in a category
*
* @package VirtueMart
* @subpackage
* @author RolandD
* @author Max Milbers
* @todo add pagination
* @link http://www.virtuemart.net
* @copyright Copyright (c) 2004 - 2010 VirtueMart Team. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* @version $Id: default.php 6297 2012-07-24 19:19:34Z Milbo $
*/

//vmdebug('$this->category',$this->category);
vmdebug('$this->category '.$this->category->category_name);
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
JHTML::_'behavior.modal' );
/* javascript for list Slide
  Only here for the order list
  can be changed by the template maker
*/
$js "
jQuery(document).ready(function () {
jQuery('.orderlistcontainer').hover(
function() { jQuery(this).find('.orderlist').stop().show()},
function() { jQuery(this).find('.orderlist').stop().hide()}
)
});
"
;

$document JFactory::getDocument();
$document->addScriptDeclaration($js);

/*$edit_link = '';
if(!class_exists('Permissions')) require(JPATH_VM_ADMINISTRATOR.DS.'helpers'.DS.'permissions.php');
if (Permissions::getInstance()->check("admin,storeadmin")) {
$edit_link = '<a href="'.JURI::root().'index.php?option=com_virtuemart&tmpl=component&view=category&task=edit&virtuemart_category_id='.$this->category->virtuemart_category_id.'">
'.JHTML::_('image', 'images/M_images/edit.png', JText::_('COM_VIRTUEMART_PRODUCT_FORM_EDIT_PRODUCT'), array('width' => 16, 'height' => 16, 'border' => 0)).'</a>';
}

echo $edit_link; */
if ( empty($this->keyword) ) {
?>

<div class="category_description">
<?php echo $this->category->category_description ?>
</div>
<?php
}

/* Show child categories */

if ( VmConfig::get('showCategory',1) and empty($this->keyword)) {
if ($this->category->haschildren) {

// Category and Columns Counter
$iCol 1;
$iCategory 1;

// Calculating Categories Per Row
$categories_per_row VmConfig::get 'categories_per_row');
$category_cellwidth ' width'.floor 100 $categories_per_row );

// Separator
$verticalseparator " vertical-separator";
?>


<div class="category-view">

<?php // Start the Output
if(!empty($this->category->children)){
foreach ( $this->category->children as $category ) {

// Show the horizontal seperator
if ($iCol == && $iCategory $categories_per_row) { ?>

<div class="horizontal-separator"></div>
<?php }

// this is an indicator wether a row needs to be opened or not
if ($iCol == 1) { ?>

<div class="row">
<?php }

// Show the vertical seperator
if ($iCategory == $categories_per_row or $iCategory $categories_per_row == 0) {
$show_vertical_separator ' ';
} else {
$show_vertical_separator $verticalseparator;
}

// Category Link
$caturl JRoute::'index.php?option=com_virtuemart&view=category&virtuemart_category_id=' $category->virtuemart_category_id );

// Show Category ?>

<div class="category floatleft<?php echo $category_cellwidth $show_vertical_separator ?>">
<div class="spacer">
<h2>
<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">
<?php echo $category->category_name ?>
<br />
<?php // if ($category->ids) {
echo $category->images[0]->displayMediaThumb("",false);
//} ?>

</a>
</h2>
</div>
</div>
<?php
$iCategory ++;

// Do we need to close the current row now?
if ($iCol == $categories_per_row) { ?>

<div class="clear"></div>
</div>
<?php
$iCol 1;
} else {
$iCol ++;
}
}
}
// Do we need a final closing row tag?
if ($iCol != 1) { ?>

<div class="clear"></div>
</div>
<?php ?>
</div>

<?php }
}
?>

<div class="browse-view">
    <?php
if (!empty($this->keyword)) {
?>

<h3><?php echo $this->keyword?></h3>
<?php
?>

  <?php if ($this->search !==null ) { ?>
    <form action="<?php echo JRoute::_('index.php?option=com_virtuemart&view=category&limitstart=0&virtuemart_category_id='.$this->category->virtuemart_category_id ); ?>" method="get">

    <!--BEGIN Search Box --><div class="virtuemart_search">
    <?php echo $this->searchcustom ?>
    <br />
    <?php echo $this->searchcustomvalues ?>
    <input name="keyword" class="inputbox" type="text" size="20" value="<?php echo $this->keyword ?>" />
    <input type="submit" value="<?php echo JText::_('COM_VIRTUEMART_SEARCH'?>" class="button" onclick="this.form.keyword.focus();"/>
    </div>
    <input type="hidden" name="search" value="true" />
    <input type="hidden" name="view" value="category" />

    </form>
<!-- End Search Box -->
<?php ?>

<?php // Show child categories
if (!empty($this->products)) {
?>

<div class="orderby-displaynumber">
<div class="width70 floatleft">
<?php echo $this->orderByList['orderby']; ?>
<?php echo $this->orderByList['manufacturer']; ?>
</div>
<div class="width30 floatright display-number"><?php echo $this->vmPagination->getResultsCounter();?><br/><?php echo $this->vmPagination->getLimitBox(); ?></div>
<div class="vm-pagination">
<?php echo $this->vmPagination->getPagesLinks(); ?>
<span style="float:right"><?php echo $this->vmPagination->getPagesCounter(); ?></span>
</div>

<div class="clear"></div>
</div> <!-- end of orderby-displaynumber -->

<h1><?php echo $this->category->category_name?></h1>

<?php
// Category and Columns Counter
$iBrowseCol 1;
$iBrowseProduct 1;

// Calculating Products Per Row
$BrowseProducts_per_row $this->perRow;
$Browsecellwidth ' width'.floor 100 $BrowseProducts_per_row );

// Separator
$verticalseparator " vertical-separator";

// Count products ?? why not just count ($this->products)  ?? note by Max Milbers
$BrowseTotalProducts 0;
foreach ( 
$this->products as $product ) {
   
$BrowseTotalProducts ++;
}

// Start the Output
foreach ( $this->products as $product ) {

// Show the horizontal seperator
if ($iBrowseCol == && $iBrowseProduct $BrowseProducts_per_row) { ?>

<div class="horizontal-separator"></div>
<?php }

// this is an indicator wether a row needs to be opened or not
if ($iBrowseCol == 1) { ?>

<div class="row">
<?php }

// Show the vertical seperator
if ($iBrowseProduct == $BrowseProducts_per_row or $iBrowseProduct $BrowseProducts_per_row == 0) {
$show_vertical_separator ' ';
} else {
$show_vertical_separator $verticalseparator;
}

// Show Products ?>

<div class="product floatleft<?php echo $Browsecellwidth $show_vertical_separator ?>">
<div class="spacer">
<div class="center">
<?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));
?>

</div><div class="clear"></div>

<div class="product-name">

<h2><?php echo JHTML::link($product->link$product->product_name); ?></h2></div>


<div class="clear"></div>
</div><!-- end of spacer -->
</div> <!-- end of product -->
<?php

   
// Do we need to close the current row now?
   
if ($iBrowseCol == $BrowseProducts_per_row || $iBrowseProduct == $BrowseTotalProducts) {?>

   <div class="clear"></div>
   </div> <!-- end of row -->
      <?php
      $iBrowseCol 
1;
   } else {
      
$iBrowseCol ++;
   }

   
$iBrowseProduct ++;
// end of foreach ( $this->products as $product )
// Do we need a final closing row tag?
if ($iBrowseCol != 1) { ?>

<div class="clear"></div>

<?php
}
?>

<!-- /div removed valerie -->
<div class="vm-pagination"><?php echo $this->vmPagination->getPagesLinks(); ?><span style="float:right"><?php echo $this->vmPagination->getPagesCounter(); ?></span></div>
<!-- /div removed valerie -->
<?php } elseif ($this->search !==null ) echo JText::_('COM_VIRTUEMART_NO_RESULT').($this->keyword' : ('$this->keyword')' '')
?>

</div><!-- end browse-view -->
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

guidocx842

  • Jr. Member
  • **
  • Posts: 74
Re: Category Page Fields for Templating
« Reply #68 on: August 03, 2012, 10:00:31 am »
Hi!! You're the best!!! Thanks!!
Last thing: at the top of the category I find the name of the category view (i.e. Garden Tools).
I think I found the code that show me that name.

Code: [Select]
// Show Category ?>

<div class="category floatleft<?php echo $category_cellwidth $show_vertical_separator ?>">

<div class="spacer">

<h2>

<a href="<?php echo $caturl ?>" title="<?php echo $category->category_name ?>">

<?php echo $category->category_name ?>

<br />

<?php // if ($category->ids) {

echo $category->images[0]->displayMediaThumb("",false);

//} ?>


</a>

</h2>

</div>

</div>

In addition I need to show the category description that I write when I create a category on virtuemart backoffice.
How can I add this description under the name of category? Thanks a lot! Have a nice day.

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
Re: Category Page Fields for Templating
« Reply #69 on: August 03, 2012, 15:12:18 pm »
Its at the top of that file
<div class="category_description">
   <?php echo $this->category->category_description ; ?>
   </div>
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

guidocx842

  • Jr. Member
  • **
  • Posts: 74
Re: Category Page Fields for Templating
« Reply #70 on: August 03, 2012, 23:55:20 pm »
You're in right! Thank you very much for your help! Thanks a lot! See you on the forum!  ;)

babouz

  • Beginner
  • *
  • Posts: 22
Re: Category Page Fields for Templating
« Reply #71 on: August 08, 2012, 15:22:24 pm »
Hi everybody,
I would like to know something. Is it possible to show custom fields of each products on category page ?

Thank you
Where is mum? She is in the bathroom. Where is dad? He is not at home. Why? I don’t know.

Sid.

  • Beginner
  • *
  • Posts: 42
    • SidFilmz
Re: Category Page Fields for Templating
« Reply #72 on: August 27, 2012, 15:13:42 pm »
So I wanted to link the thumbnail on my Category page to an external URL (a YouTube video), but I wanted the video to popup in a modal window. I installed RokBox and updated the product thumbnail code on my Category page to this:

Code: [Select]
<?php echo JHTML::_('link'JRoute::_($product->product_url),$product->images[0]->displayMediaThumb('class="catImage" border="0"',false),'rel="rokbox"'); ?>

It works beautifully.

troken

  • Beginner
  • *
  • Posts: 13
Re: Category Page Fields for Templating
« Reply #73 on: September 01, 2012, 11:11:03 am »
Hello
how I can remove the link to the product name in category template?
In this
Code: [Select]
<?php echo JHTML::link($product->link$product->product_name); ?> remove link
Thanks

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10352
  • VirtueMart Version: 3+
Re: Category Page Fields for Templating
« Reply #74 on: September 03, 2012, 15:39:26 pm »
Hello
how I can remove the link to the product name in category template?
In this
Code: [Select]
<?php echo JHTML::link($product->link$product->product_name); ?> remove link
Thanks

You want just the name?

<?php echo $product->product_name ?>
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)