Author Topic: How to add a View All/View Less Product Browse Functionality  (Read 8826 times)

BigAlStorm

  • Beginner
  • *
  • Posts: 32
Hi guys

Open

administrator/components/com_virtuemart/classes/pageNavigation.class.php

Change


Quote

 // build the html select list
    if (empty( $link)) {
    $html = ps_html::selectList( 'limit', $this->limit, $limits, 1, '',  'onchange="this.form.submit();"' );
    } else {
      $current = vmRoute($link.'&limit='.$this->limit);
      $html = ps_html::selectList( 'limit', $current, $limits, 1, '',  'onchange="location.href=this.value"' );
    }
    $html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />";
    return $html;
  }

to


Quote
// build the html select list

   if ($link == 6000)
{
    $html = ps_html::selectList( 'limit', $this->limit, $limits, 1, '',  'onchange="this.form.submit();"' );
   
   $currents = vmRoute($link.'&limit='.$this->limit/500);
     $class_att = 'class="button"';
      $text = 'View All, 12';
      




$html = vmCommonHTML::hyperlink( $currents, $text, _self, $text, 'onclick="javascript:GoToBack();"', '',  'limit', 'onclick="javascript:GoToBack();"', $limits );
   


}

else {
      $current = vmRoute($link.'&limit='.$this->limit);
      $html = ps_html::selectList( 'limit', $current, $limits, 1, '',  'onchange="location.href=this.value"' );
   

   $currents = vmRoute($link.'&limit='.$this->limit*500);
     $class_att = 'class="button"';
      $text = 'View All';
   $currentz = vmRoute($link.'&limit='.$this->limit/500);
      $href1 = vmCommonHTML::hyperlink( $currents, $text, _self, $text, 'onclick="javascript:GoToBack();"', '',  'limit', 'onclick="javascript:GoToBack();"', $limits );
   $href2 = '<a href=\''.$currentz.'\'>&nbsp;View Less</a>';




$html = $href1.$href2;


}

    $html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />";

    return $html;

  }



To add images simply add in some image code around the $html output

shendrik

  • Beginner
  • *
  • Posts: 1
Re: How to add a View All/View Less Product Browse Functionality
« Reply #1 on: June 06, 2010, 09:56:13 am »
Hi, I tried your code and I have the following error

Fatal error: Call to undefined method vmPageNav:: writePagesCounter () in  .../browse/includes/browse_pagenav.tpl.php on line 19

Can you help?

Christopher

  • Jr. Member
  • **
  • Posts: 93
    • CDTi
Re: How to add a View All/View Less Product Browse Functionality
« Reply #2 on: July 22, 2010, 11:00:00 am »
BigAlStorm,

You are a genius and have saved my skin - thank you very much indeed! - I've been trawling the forums for several days looking for an elegant solution to this issue and your code is perfect for my needs.

Cheers

Christopher
There are 10 types of people in the world:
Those who understand binary and those who don't

Fariida

  • Beginner
  • *
  • Posts: 39
Re: How to add a View All/View Less Product Browse Functionality
« Reply #3 on: October 07, 2010, 16:13:03 pm »
Hi is there any way to make individual text links?
For example

Display # 15 | 30 | 60

roman5527

  • Jr. Member
  • **
  • Posts: 211
Re: How to add a View All/View Less Product Browse Functionality
« Reply #4 on: December 15, 2011, 13:02:04 pm »
Hi guys

Open

administrator/components/com_virtuemart/classes/pageNavigation.class.php

Change


Quote

 // build the html select list
    if (empty( $link)) {
    $html = ps_html::selectList( 'limit', $this->limit, $limits, 1, '',  'onchange="this.form.submit();"' );
    } else {
      $current = vmRoute($link.'&limit='.$this->limit);
      $html = ps_html::selectList( 'limit', $current, $limits, 1, '',  'onchange="location.href=this.value"' );
    }
    $html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />";
    return $html;
  }

to


Quote
// build the html select list

   if ($link == 6000)
{
    $html = ps_html::selectList( 'limit', $this->limit, $limits, 1, '',  'onchange="this.form.submit();"' );
   
   $currents = vmRoute($link.'&limit='.$this->limit/500);
     $class_att = 'class="button"';
      $text = 'View All, 12';
      




$html = vmCommonHTML::hyperlink( $currents, $text, _self, $text, 'onclick="javascript:GoToBack();"', '',  'limit', 'onclick="javascript:GoToBack();"', $limits );
   


}

else {
      $current = vmRoute($link.'&limit='.$this->limit);
      $html = ps_html::selectList( 'limit', $current, $limits, 1, '',  'onchange="location.href=this.value"' );
   

   $currents = vmRoute($link.'&limit='.$this->limit*500);
     $class_att = 'class="button"';
      $text = 'View All';
   $currentz = vmRoute($link.'&limit='.$this->limit/500);
      $href1 = vmCommonHTML::hyperlink( $currents, $text, _self, $text, 'onclick="javascript:GoToBack();"', '',  'limit', 'onclick="javascript:GoToBack();"', $limits );
   $href2 = '<a href=\''.$currentz.'\'>&nbsp;View Less</a>';




$html = $href1.$href2;


}

    $html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />";

    return $html;

  }



To add images simply add in some image code around the $html output


Hi , when i putt this code , i see

Not Found

The requested URL /&limit=6000 was not found on this server.

please help me

roman5527

  • Jr. Member
  • **
  • Posts: 211
Re: How to add a View All/View Less Product Browse Functionality
« Reply #5 on: December 15, 2011, 23:38:24 pm »
Please  help me .

mizu

  • Beginner
  • *
  • Posts: 33
Re: How to add a View All/View Less Product Browse Functionality
« Reply #6 on: December 19, 2011, 16:41:12 pm »
too bad this snipped doesn't work for me.
The 'view less' does nothing but occasionally some random behavior, like displaying one item.

A working solution anyone?


positronio

  • Beginner
  • *
  • Posts: 20
Re: How to add a View All/View Less Product Browse Functionality
« Reply #7 on: January 26, 2012, 14:11:36 pm »
hi for whom the above doesn't work or want to have an option in adding a view all in the dropdownbox namely "list length" at the administrator backend of joomla. The code is based on the above so many thanks to bigallstorm. A couple of words about the code:
The code adds in the front end in the dropdown box an all option and like bigallstorm's code, adds next to the dropdown box a link named view all.
Also it adds in the back end for virtuemart component in the dropdown box an all option. (very helpful in my opinion). For using joomfish,
i have added at /administrator/components/com_virtuemart/languages/common   'PHPSHOP_SHOW_PRODUCTS' => 'View all', and    'PHPSHOP_ALL_DROP_DOWN_BOX' => 'All'.
so go to administrator/components/com_virtuemart/classes/pageNavigation.class.php

and find

 if (empty( $link)) {
      $limits[50] = 50;
    } else {
      $limits[vmRoute($link.'&limit=50')] = 50;
    }

    // build the html select list
    if (empty( $link)) {
    $html = ps_html::selectList( 'limit', $this->limit, $limits, 1, '',  'onchange="this.form.submit();"' );
    } else {
      $current = vmRoute($link.'&limit='.$this->limit);
      $html = ps_html::selectList( 'limit', $current, $limits, 1, '',  'onchange="location.href=this.value"' );
    }
    $html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />";
    return $html;
  }

and replace it with


 global $VM_LANG;
       if (empty( $link)) {
      $limits[50000] = $VM_LANG->_('PHPSHOP_ALL_Drop_Down_Box');
    } else {
      $limits[vmRoute($link.'&limit=50000')] = $VM_LANG->_('PHPSHOP_ALL_Drop_Down_Box');
    }

     // build the html select list
  if (empty( $link)) {
      $html = ps_html::selectList( 'limit',$this->limit, $limits, 1, '',  'onchange="this.form.submit();"' );
  } else {
      $current = vmRoute($link.'&limit='.$this->limit);
      $html = ps_html::selectList( 'limit', $current, $limits, 1, '',  'onchange="location.href=this.value"' );
      $href3 = $html; 
      $currents = vmRoute($link.'&limit=50000');
      $class_att = 'class="button"';
      global $VM_LANG;
      $text = $VM_LANG->_('PHPSHOP_SHOW_PRODUCTS');
      $href1 = vmCommonHTML::hyperlink($currents,$text, _self, $text,'onclick="javascript:GoToBack();"', '',  'limit', 'onclick="javascript:GoToBack();"', $limits );
   
   $html = $href3.$href1;
  }
    $html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />";
    return $html;
  }

good luck i hope you find it useful.

creativeweb

  • Beginner
  • *
  • Posts: 3
Re: How to add a View All/View Less Product Browse Functionality
« Reply #8 on: March 02, 2012, 22:54:22 pm »
Hi

This is all very useful but can someone please tell me what code to remove and replace if I want to:

Keep both the dropdown with numbers and a View ALL link next to it but NO View Less Link

If someone could please let me know that would be very much appreciated, happy to send a paypal donation for a fast response

Thanks

positronio

  • Beginner
  • *
  • Posts: 20
Re: How to add a View All/View Less Product Browse Functionality
« Reply #9 on: March 18, 2012, 19:32:46 pm »
What exactly you don't understand. See the above post of mine.

creativeweb

  • Beginner
  • *
  • Posts: 3
Re: How to add a View All/View Less Product Browse Functionality
« Reply #10 on: March 18, 2012, 19:54:30 pm »
Thanks for reply, I did not want a VIEW LESS link, I only wanted VIEW ALL link but I got someone to help me in the end and used this code instead:

function getLimitBox ( $link = '') {
   $limits = array();

   if (!empty($link) && strpos( 'limitstart=', $link) === false) {  // insert limitstart in url if missing // shumisha
     $link .= '&limitstart='.$this->limitstart;
   }
   for ($i=5; $i <= 30; $i+=5) {
     if (empty( $link)) {
       $limits[$i] = $i;
     } else {
       $limits[vmRoute($link.'&limit='.$i)] = $i;
     }
   }
   if (empty( $link)) {
     $limits[50] = 50;
   } else {
     $limits[vmRoute($link.'&limit=50')] = 50;
   }

   // build the html select list
  /* if (empty( $link)) {
   $html = ps_html::selectList( 'limit', $this->limit, $limits, 1, '',  'onchange="this.form.submit();"' );
   } else {
     $current = vmRoute($link.'&limit='.$this->limit);
     $html = ps_html::selectList( 'limit', $current, $limits, 1, '',  'onchange="location.href=this.value"' );
   }
   $html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />";
   return $html;*/

global $VM_LANG;
if (empty( $link)) {
 $limits[50000] = 'View All';
} else {
 $limits[vmRoute($link.'&limit=50000')] = 'View All';
}

// build the html select list
if (empty( $link)) {
 $html = ps_html::selectList( 'limit',$this->limit, $limits, 1, '',  'onchange="this.form.submit();"' );
} else {
 $current = vmRoute($link.'&limit='.$this->limit);
 $html = ps_html::selectList( 'limit', $current, $limits, 1, '',  'onchange="location.href=this.value"' );
 $href3 = $html; 
 $currents = vmRoute($link.'&limit=50000');
 $class_att = 'class="button"';
 global $VM_LANG;
 $text = $VM_LANG->_('PHPSHOP_SHOW_PRODUCTS');
 $href1 = vmCommonHTML::hyperlink($currents,$text, _self, $text,'onclick="javascript:GoToBack();"', '',  'limit', 'onclick="javascript:GoToBack();"', $limits );

 $html = $href3.$href1;
}


$html .= "\n<input type=\"hidden\" name=\"limitstart\" value=\"$this->limitstart\" />";
 
 
return $html;

 }