VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Products, Prices, Tax and Categories VM 1.1 => Topic started by: Klaus Becker on May 09, 2008, 13:06:51 pm

Title: How can i hide Headertext on Toplevel Category
Post by: Klaus Becker on May 09, 2008, 13:06:51 pm
I have a Toplevel Category without any product - only the subcategories hold some products.
If i click on this Toplevel Category the Subcategories are listed correct.
But the next line shows the headertext such as Name,Article,Price,Picture....

I need this not, because i have already no product there

How can i hide this?

Sorry for my poor english

Klaus
Title: Re: How can i hide Headertext on Toplevel Category
Post by: 8lebel on August 02, 2008, 17:36:21 pm
Hallo Klaus,

Do you have solve your problem, I have the same one.....not in the toplevel category but in the sub-category.

Best regards,

Jean-Philippe
Title: Re: How can i hide Headertext on Toplevel Category
Post by: akerman on August 03, 2008, 22:02:00 pm
You are so lucky today guys!  ;D

Here's the solution! (I've spent the better part of the day to solve this...)

I'm going to be really pedagogical about this, because I know there are a few VM users out there looking for this, except you of course, so bare with me. OK, here we go:

This is for VM 1.1.X - nothing else.
And backup your files - Better safe than sorry.


1. First I just want to show from where we pick up the class parameter.
That we do from 'ps_product_category.php' in '/www-root/administrator/component/com_virtumart/classes/..'

(It's the first function line and the last that's interesting).

Code: [Select]
/**
* Function to calculate and return the number of products in category $category_id
* @author pablo
* @author soeren
*
* @param int $category_id
* @return int The number of products found
*/
function product_count($category_id) {
global $perm;
$ps_vendor_id = $_SESSION["ps_vendor_id"];

$db = new ps_DB;
if( !isset($GLOBALS['category_info'][$category_id]['product_count'] )) {

$count  = "SELECT count(#__{vm}_product.product_id) as num_rows from #__{vm}_product,#__{vm}_product_category_xref, #__{vm}_category WHERE ";
$q = "";
if (defined('_VM_IS_BACKEND' )) {
if (!$perm->check( "admin,storeadmin")) {
$q .= "#__{vm}_product.vendor_id = '$ps_vendor_id' AND ";
}
}
$q .= "#__{vm}_product_category_xref.category_id='$category_id' ";
$q .= "AND #__{vm}_category.category_id=#__{vm}_product_category_xref.category_id ";
$q .= "AND #__{vm}_product.product_id=#__{vm}_product_category_xref.product_id ";
//$q .= "AND #__{vm}_product.product_parent_id='' ";
if( !$perm->check("admin,storeadmin") ) {
$q .= " AND product_publish='Y'";
if( CHECK_STOCK && PSHOP_SHOW_OUT_OF_STOCK_PRODUCTS != "1") {
$q .= " AND product_in_stock > 0 ";
}
}
$count .= $q;
$db->query($count);
$db->next_record();
$GLOBALS['category_info'][$category_id]['product_count'] = $db->f("num_rows");
}
return $GLOBALS['category_info'][$category_id]['product_count'];
}


2. Now we edit 'shop.browse.php' in '/www-root/administrator/component/com_virtumart/html/..' Add the rows in red.


   // NOW START THE PRODUCT LIST
   $tpl = vmTemplate::getInstance();
   
   if( $category_id ) {
      /**
       * CATEGORY DESCRIPTION - Updated ROA w thumb image and prod counter from ps_product_category
       */      
      $browsepage_lbl = $category_name;
      $tpl->set( 'browsepage_lbl', $browsepage_lbl );      
      
      $category_thumb_image = $ps_product_category->get_cat_thumb_img($category_id);
            $tpl->set( 'browse_category_thumb_image', $category_thumb_image );   

      $tpl->set( 'desc', $desc );
      
      $count_prod = $ps_product_category->product_count($category_id);
      $tpl->set( 'count_products', $count_prod );   
   
      $category_childs = $ps_product_category->get_child_list($category_id);
      $tpl->set( 'categories', $category_childs );
      $navigation_childlist = $tpl->fetch( 'common/categoryChildlist.tpl.php');
      $tpl->set( 'navigation_childlist', $navigation_childlist );

-------------------------------------------------------------------------------------------
3. Then we edit 'browse_listtable.tpl.php' in '/www-root/components/com_virtuemart/themes/your-theme/templates/browse/includes/..' 
We insert the red code in the beginning of the file:


<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?>

<?php echo $buttons_header // The PDF, Email and Print buttons ?>
<?php echo $browsepage_header // The heading, the category description ?>
<?php echo $parameter_form // The Parameter search form ?>
<?php echo $orderby_form // The sort-by, order-by form PLUS top page navigation ?>

<?php if ( $count_products > 0 ) { ?>

<?php
$data =array(); // Holds the rows of products
$i = 1; $row = 0;  // Counters


... and in the end of the file.


// Display the table
echo $table->toHtml();
?>
<br class="clr" /><br />

<?php } ?>

<?php
// Show Featured Products
if( $this->get_cfg( 'showFeatured', 1 )) {
    /* featuredproducts(random, no_of_products,category_based) no_of_products 0 = all else numeric amount
    edit featuredproduct.tpl.php to edit layout */
    echo $ps_product->featuredProducts(true,10,true);
} ?>
<?php echo $recent_products ?>
<?php echo $browsepage_footer ?>

-----------------------------------------------------------------------------------------

Thereby we have encapsulated the display for header text to only show up when a product is present in the category. And that goes for all category levels!  :)


If you want you can check it out on my site.
http://www.infoclip.se/index.php?option=com_virtuemart&Itemid=99

It's in Swedish, but you can navigate with the category images/texts or the menu to the right to see how it looks. (Never mind my long category descriptions and odd images, it's a work in progress...  :D )


Good luck!

Regards
Akerman
Title: Re: How can i hide Headertext on Toplevel Category
Post by: 8lebel on August 04, 2008, 10:26:36 am
Hello Akerman, I will try the modification now!
THANK YOU, THANK YOU !!!!!!!!  :)
Title: Re: How can i hide Headertext on Toplevel Category
Post by: 8lebel on August 04, 2008, 11:31:10 am
IT'S WORKING NOW !!!!! TACK !!!!!  :)

Have a look. http://www.ste-equip.fr

For all: the 'shop.browse.php' file is in the html directory
Title: Re: How can i hide Headertext on Toplevel Category
Post by: akerman on August 04, 2008, 13:46:17 pm
Hi, good to hear!

Oh, and I've changed the directory to 'html' of course. (Darn cut-n-paste!  ;) )


Regards
Akerman
Title: Re: How can i hide Headertext on Toplevel Category
Post by: akerman on August 10, 2008, 14:12:22 pm
UPDATE!  :o

Noticed the other day that my solution inadvertently affect the 'search' function.
Since 'shop.browse' also holds the search function the solution above does do the search correct, but it never shows the result: Since I made an If-loop testing for the number of products.  :-\

No worries. We only need to include the search step as well. And here's the fix:


1. In  'shop.browse.php' in '/www-root/administrator/component/com_virtumart/html/..' Add the rows in red. Approx. about line 245:

    }
    else {
       $tpl->set( 'orderby_form', '' );
    }
   
   $db_browse->query( $list );
   $db_browse->next_record();

   $products_per_row = (!empty($category_id)) ? $db_browse->f("products_per_row") : PRODUCTS_PER_ROW;

   $count_prod = $products_per_row;
   $tpl->set( 'count_products', $count_prod );


   if( $products_per_row < 1 ) {
      $products_per_row = 1;
   }
   $buttons_header = '';



   /**
    *   Start caching all product details for a later loop
    *
    **/
-------------------------------------------------------------------------------------------

This way we include the 'number_of_rows' parameter into our 'count_products' if and when we decide to go through the 'shop.browse.php' by doing a 'Search' instead of a normal listing.


Questions, ideas, applause?  :D


If you're happy with the solution, please mark the first message in the thread with "Solved" and with the green solved icon. (...yes you Claus...  ;) )


Regards
Akerman
Title: Re: How can i hide Headertext on Toplevel Category
Post by: Goldrolly07 on August 17, 2008, 22:21:51 pm
There probably is a way to customize the shown content in a flat listed category right?

I want to get rid of the SKU and view details column, resort the columns (ie: NAME - DESCRIPTION - PRICE -  and change the other column names to dutch.

In which file do I need to do this?

Thnx!
Title: Re: How can i hide Headertext on Toplevel Category
Post by: akerman on August 19, 2008, 09:51:53 am
Ok, I'll give you the directions on how to, but first I'm going to hand out some common 'Forum' sence, and this is nothing personal Goldrolly07, it's to all posters:

Please, please post a new thread when you ask new questions.

I know and understand that it sometimes can be hard to distinguish between similar issues, but the procedure is that the initial question/topic in a thread guides the content of the same.

In the last couple of months, this forum has become swamped with threads that not adhere to forum etiquette and the moderators probably have their hands full. I personally tend to withdraw from 'messy' threads' or threads with 'loose' contents like 'My VM is broke. Why?' So please try to help us all by helping yourself:

1. Search forum first:
2. Ongoing fresh thread on topic? Not older than 120 days or so? = Participate in thread.
3. Not answered before = New question = New Thread (with details on system, issue, goal)
     Subject = A precise description of the issue/question.

Ok, just wanted to get that of my chest. Thanks  :)

------------------------------------------------------------------------------------------
In order to present a flat list of products with reduced headings, one way to do this is to to perform the following:

Backup
 
First decide what browse template to use. Refer to the manual if you don't know how to.

1. In VM backend: Select Config/Layout/Theme Configuration/Flat List (Table)
2. In VM backend: Select Product/Categories/Category Description/Show x products per row: 1
3. Go to /www/components/com_virtuemart/themes/your_theme/templates/browse/includes/browse_listtable.tpl.php and edit all you like.

Including an example of the code in 'browse_listtable.tpl.php' that gives you the example below. See picture
Code: [Select]
<?php
$data 
=array(); // Holds the rows of products
$i 1$row 0;  // Counters


// Table header
$tableheader[] = $VM_LANG->_('PHPSHOP_PRODUCT_FORM_THUMB_IMAGE');
$tableheader[] = $VM_LANG->_('PHPSHOP_CART_NAME');
if( 
_SHOW_PRICES && $auth['show_prices'] )  {
 $tableheader[] =  '<div style="text-align:right; font-weight:bold;">'.$VM_LANG->_('PHPSHOP_CART_PRICE');
}

/* $tableheader[] = $VM_LANG->_('PHPSHOP_CART_SKU'); */
/*
$tableheader[] = $VM_LANG->_('PHPSHOP_PRODUCT_DESC_TITLE');
if( _SHOW_PRICES && $auth['show_prices'] && USE_AS_CATALOGUE != '1' ) {
$tableheader[] = $VM_LANG->_('PHPSHOP_CART_ACTION');
}
*/


// Creates a new HTML_Table object that will help us
// to build a table holding all the products

$table =& new HTML_Table('width="100%"');

$table->addRow$tableheader'class="sectiontableheader"''th'true );

foreach( 
$products as $product ) {

foreach( $product as $attr => $val ) {
// Using this we make all the variables available in the template
// translated example: $this->set( 'product_name', $product_name );
$this->set$attr$val );
}

$data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
ps_product::image_tag$product['product_thumb_image'] )
'</a>';

$data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'.$product['product_name'].'</a>''<br />'$product['product_s_desc'];




/* $data[$row][] = $product['product_s_desc'];   
if( $product['has_addtocart'] ) {
$data[$row][] = $product['form_addtocart']; 
}
/* else {
$data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
. $product['product_details']
. '</a>';
}
*/



/* $data[$row][] = $product['product_sku']; */ 
     

if( _SHOW_PRICES && $auth['show_prices'] ) { 
$data[$row][] = '<div style="text-align:right;">'$product['product_price'] ;
}



$row++;

}


// Loop through each row and build the table
foreach($data as $key => $value) {

$table->addRow$data[$key], 'class="sectiontableentry'.$i.'"''td'true );
$i $i == 1;
}




// Display the table
echo $table->toHtml();
?>

<br class="clr" /><br /><br /><br /><br /><br /><br />

Good luck, and remember the 1-2-3 step when posting, ok?  ;)

Regards
Akerman

[attachment deleted by admin]
Title: Re: How can i hide Headertext on Toplevel Category
Post by: Goldrolly07 on August 24, 2008, 11:54:15 am
Thanx for your reply.... I will give it a go. (managed to get the product page editted myself but had no clue where the php file for category list was)

And believe me I searched my butt off. Clearly I didn't search with the right keywords ;)
Title: Re: How can i hide Headertext on Toplevel Category
Post by: andrewau on October 12, 2008, 03:14:50 am
Hi,

Thanks to akerman for his help. I used your template but also wanted the add to cart in the table list as well. Thought I would share my modified version of your code for others to use:

Code: [Select]
<?php if( !defined'_VALID_MOS' ) && !defined'_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
mm_showMyFileName(__FILE__); ?>


<?php echo $buttons_header // The PDF, Email and Print buttons ?>
<?php echo $browsepage_header // The heading, the category description ?>
<?php echo $parameter_form // The Parameter search form ?>
<?php echo $orderby_form // The sort-by, order-by form PLUS top page navigation ?>

<?php
$data 
=array(); // Holds the rows of products
$i 1$row 0// Counters

// Table header
$tableheader[] = $VM_LANG->_('PHPSHOP_PRODUCT_FORM_THUMB_IMAGE');
$tableheader[] = $VM_LANG->_('PHPSHOP_CART_NAME');
if( 
_SHOW_PRICES && $auth['show_prices'] ) {
$tableheader[] = $VM_LANG->_('PHPSHOP_CART_PRICE');
}

$tableheader[] = $VM_LANG->_('PHPSHOP_CART_ADD_TO');

$table =& new HTML_Table('width="100%"');

$table->addRow$tableheader'class="sectiontableheader"''th'true );

foreach( 
$products as $product ) {

foreach( $product as $attr => $val ) {
// Using this we make all the variables available in the template
// translated example: $this->set( 'product_name', $product_name );
$this->set$attr$val );
}

$data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
ps_product::image_tag$product['product_thumb_image'] )
'</a>';

$data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'.$product['product_name'].'</a>''<br />'$product['product_s_desc'];
if( _SHOW_PRICES && $auth['show_prices'] ) { 
$data[$row][] = '<div style="text-align:right;">'$product['product_price'] ;

// $data[$row][] = $product['product_s_desc'];   
if( $product['has_addtocart'] ) {
$data[$row][] = $product['form_addtocart']; 
}
else {
$data[$row][] = '<a href="'.$product['product_flypage'].'" title="'.$product['product_name'].'">'
. $product['product_details']
. '</a>';
}

/* $data[$row][] = $product['product_sku']; */ 
     


}

$row++;
}

// Loop through each row and build the table
foreach($data as $key => $value) {

$table->addRow$data[$key], 'class="sectiontableentry'.$i.'"''td'true );
$i $i == 1;
}

// Display the table
echo $table->toHtml();
?>

<br class="clr" /><br /><br /><br /><br /><br /><br />
Title: Re: How can i hide Headertext on Toplevel Category
Post by: akerman on October 12, 2008, 07:57:17 am
Hi,

thanx for the contribution! I'm sure there is always someone that'll be happy for additions in 'how-to-edit' and adopt the browse page.  :)

Regards
Akerman
Title: Re: How can i hide Headertext on Toplevel Category
Post by: bunak on November 29, 2008, 12:23:45 pm
I also ask oneself, how hide header of table of products in case the category do not have products.

My variant of solutions, in compare with Akerman's solutions, is do not exec added query to get count of products of selected category.

And so.
1. In 'shop.browse.php' in '/www-root/administrator/component/com_virtumart/html/..' Add the rows in red.

for account the count of products of selected category

   $count_products = 0; // count of products for this category
   /*** Start printing out all products (in that category) ***/
   while ($db_browse->next_record()) {
      
      $count_products++; // increase count of products for this category

pass the count of products of selected category to productListStyle browse page
   $tpl->set('ps_product',$ps_product);
   
   $tpl->set('count_products',$count_products); // set parameter to productListStyle - browse page

   echo $tpl->fetch( $tpl->config->get( 'productListStyle' ) );

2. And then need do some as Akerman edit in 3 step.

-------------------------------------------------------------------------------------------
3. Then we edit 'browse_listtable.tpl.php' in '/www-root/components/com_virtuemart/themes/your-theme/templates/browse/includes/..' 
We insert the red code in the beginning of the file:

<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?>
<?php echo $buttons_header // The PDF, Email and Print buttons ?>
<?php echo $browsepage_header // The heading, the category description ?>
<?php echo $parameter_form // The Parameter search form ?>
<?php echo $orderby_form // The sort-by, order-by form PLUS top page navigation ?>
<?php if ( $count_products > 0 ) { ?>
<?php
$data =array(); // Holds the rows of products
$i = 1; $row = 0;  // Counters

... and in the end of the file.

// Display the table
echo $table->toHtml();
?>
<br class="clr" /><br />
<?php } ?>
<?php
// Show Featured Products
if( $this->get_cfg( 'showFeatured', 1 )) {
    /* featuredproducts(random, no_of_products,category_based) no_of_products 0 = all else numeric amount
    edit featuredproduct.tpl.php to edit layout */
    echo $ps_product->featuredProducts(true,10,true);
} ?>
<?php echo $recent_products ?>
<?php echo $browsepage_footer ?>
-----------------------------------------------------------------------------------------
Akerman
Title: Re: How can i hide Headertext on Toplevel Category
Post by: strats on November 29, 2008, 12:28:43 pm
Excellent!!! Many thanks for this mod akerman :)
Title: Re: How can i hide Headertext on Toplevel Category
Post by: akerman on December 01, 2008, 17:30:59 pm
Thanks 'strats'!

Always nice to get reviewed.  :D

Regards
Akerman
Title: Re: How can i hide Headertext on Toplevel Category
Post by: sitebuildernow on April 08, 2009, 23:47:15 pm
I don't know if you'll get this but I wanted to say thank you!!! Your mods made my day - I was really frustrated with the product list headers showing up on my main categories (when no products were listed under the top category). You rock!
Title: Re: How can i hide Headertext on Toplevel Category
Post by: bunak on August 08, 2010, 15:00:38 pm
Hi all.

I propose a new modification of hack, that hide header text such as Name, Article, Price, Picture in selected categories with no products.

Edit 'browse_listtable.tpl.php' in '/www-root/components/com_virtuemart/themes/your-theme/templates/browse/includes/..'

Insert the red code in the beginning of the file:
Quote
<?php if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' ); ?>
<?php echo $buttons_header // The PDF, Email and Print buttons ?>
<?php echo $browsepage_header // The heading, the category description ?>
<?php echo $parameter_form // The Parameter search form ?>
<?php
   // bunak - hide header table of products ----------------->>
   if (count($products) > 0) {
   // bunak - hide header table of products <<-----------------
?>
<?php echo $orderby_form // The sort-by, order-by form PLUS top page navigation ?>

... and in the end of the file.
Quote
...
// Display the table
echo $table->toHtml();
?>
<br class="clr" /><br />
<?php
   // bunak - hide header table of products ----------------->>
   }
   // bunak - hide header table of products <<-----------------
?>
<?php
// Show Featured Products
if( $this->get_cfg( 'showFeatured', 1 )) {
...

Where the variable $products is the VirtueMart's array of products.

Attach 'browse_listtable.tpl.php' that modified by this hack.

[attachment cleanup by admin]
Title: Re: How can i hide Headertext on Toplevel Category
Post by: rb on August 08, 2010, 15:45:46 pm
and here's another method:
http://forum.virtuemart.net/index.php?topic=62417.msg206447#msg206447
Title: Re: How can i hide Headertext on Toplevel Category
Post by: bunak on August 08, 2010, 17:11:52 pm
But the our method if compared with your - does no extra operators. It's important for optimization of work.