Author Topic: display products in the same category on flypage.  (Read 14197 times)

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10359
  • VirtueMart Version: 3+
Re: display products in the same category on flypage.
« Reply #15 on: April 12, 2011, 14:52:38 pm »
what do you mean pagination?
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

Vichell10

  • Beginner
  • *
  • Posts: 5
Re: display products in the same category on flypage.
« Reply #16 on: April 13, 2011, 05:50:22 am »
hi, like this http://www.onlinehowto.net/Tutorials/AJAX/Paging-using-PHP-MySQL-with-AJAX/1357

pagination.class.php coz i want to post all the products with same category as the product in the flypage at the bottom of flypage but i want to limit it to 6 products so i need next previous button :)

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10359
  • VirtueMart Version: 3+
Re: display products in the same category on flypage.
« Reply #17 on: April 13, 2011, 13:39:40 pm »
I dont not know how, i am not a coder

But you can limit that code easily
J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

Vichell10

  • Beginner
  • *
  • Posts: 5
Re: display products in the same category on flypage.
« Reply #18 on: April 13, 2011, 14:49:29 pm »
Hi, tnx for the reply i guess i figured it out :)

 <?php
$page_name= $_SERVER['PHP_SELF']; //  If you use this code with a different page ( or file ) name then change this

$start=$_GET['start'];                        // To take care global variable if OFF
if(!($start > 0)) {                         // This variable is set to zero for the first page
$start = 0;
}

$eu = ($start -0);               
$limit = 6;                                 // No of records to be shown per page.
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
 
$db = new ps_DB;
$db->query( "SELECT COUNT(*) AS cnt FROM #__{vm}_product p,#__{vm}_product_category_xref pc, #__{vm}_category c
            WHERE p.product_publish='Y' AND pc.product_id = p.product_id AND pc.category_id = c.category_id AND c.category_id = '$category_id' AND p.product_id != '$product_id'
            AND p.product_full_image <> '' ");
$db->next_record();
$nume = $db->f('cnt');


   $q = "SELECT p.product_id, p.product_name, p.product_thumb_image, p.product_s_desc, c.category_name, c.category_flypage
            FROM #__{vm}_product p,#__{vm}_product_category_xref pc, #__{vm}_category c
            WHERE p.product_publish='Y' AND pc.product_id = p.product_id AND pc.category_id = c.category_id AND c.category_id = '$category_id' AND p.product_id != '$product_id'
            AND p.product_full_image <> '' ORDER BY p.product_name LIMIT $eu, $limit";
   

///// Variables set for advance paging///////////
$p_limit=6; // This should be more than $limit and set to a value for whick links to be breaked

$p_f=$_GET['p_f'];                        // To take care global variable if OFF
if(!($p_f > 0)) {                         // This variable is set to zero for the first page
$p_f = 0;
}



$p_fwd=$p_f+$p_limit;
$p_back=$p_f-$p_limit;
//////////// End of variables for advance paging ///////////////
/////////////// Start the buttom links with Prev and next link with page numbers /////////////////
echo "<div style='margin-left:3px; margin-top:0px; float:inherit; display:inline;'>";
if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back' style='font-family: 'Century Gothic'; font-size:12px; color:#796e69;'>PREV</a>"; }

//echo "</td><td  align='left' width='10%'>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0 and ($back >=$p_f)) {
print "<a href='$page_name?start=$back&p_f=$p_f' style='font-family: 'Century Gothic'; font-size:12px; color:#796e69;'>PREV</a>";
}
//////////////// Let us display the page links at  center. We will not display the current page as a link ///////////
//echo "</td><td>";
for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
if($i <> $eu){
$i2=$i+$p_f;
echo " <a href='$page_name?start=$i&p_f=$p_f'>$i</a> ";
}
//else { echo "<font face='Verdana' size='4' color=red>$i</font>";}        /// Current page is not displayed as link and given font color red

}

//echo "</td><td>";
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume and $this1 <($p_f+$p_limit)) {
echo "<a href='$page_name?start=$next&p_f=$p_f' style='font-family: 'Century Gothic'; font-size:12px; color:#796e69;>NEXT</a>";
}
//echo "</td><td  align='right' width='20%'>";
if($p_fwd < $nume){
print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd' style='font-family: 'Century Gothic'; font-size:12px; color:#796e69;>NEXT</a>";
}
echo "</div><br>";


if( $db->next_record() )  {
   $flypage = $db->f('category_flypage');
   $db->reset();
   echo '<br><table width="100%" align="center" cellspacing="0px">';
   echo '<tr>';
   echo '<td>';
   while( $rs = $db->next_record() ) {
      ?>
      <a href="<?php  $sess->purl(URL . "index.php?page=shop.product_details&flypage=$flypage&product_id=" . $db->f("product_id") . "&category_id=$category_id" ) ?>">
      <img src="<?php echo $mosConfig_live_site;?>/components/com_virtuemart/shop_image/product/<?php $db->p("product_thumb_image");?>"/>
      </a>
      <?php
   echo '<td>';
   } //while
echo '<tr></table>';
} // if

?>

mathrem

  • Beginner
  • *
  • Posts: 6
Re: display products in the same category on flypage.
« Reply #19 on: May 25, 2011, 19:02:01 pm »
Sorry i'm french and i dont understand the way to add product_thumb_image
where do i put

while( $db->next_record() ) {
   $thumb = $db->f("product_thumb_image");
   if($image){
      echo "<img src="IMAGEURL."product/".$image;
   } else {
      // display placeholder art instead
}
 thanks

mathrem

  • Beginner
  • *
  • Posts: 6
Re: display products in the same category on flypage.
« Reply #20 on: May 26, 2011, 09:11:14 am »
How to display the thumbs of the products who are in the same category on flypage?
Its OK for the product name and link but not for the thumb?
Thanks for the answer

ronydjohan

  • Beginner
  • *
  • Posts: 42
Re: display products in the same category on flypage.
« Reply #21 on: April 09, 2013, 08:24:36 am »
Hi, tnx for the reply i guess i figured it out :)

 <?php
$page_name= $_SERVER['PHP_SELF']; //  If you use this code with a different page ( or file ) name then change this

$start=$_GET['start'];                        // To take care global variable if OFF
if(!($start > 0)) {                         // This variable is set to zero for the first page
$start = 0;
}

$eu = ($start -0);               
$limit = 6;                                 // No of records to be shown per page.
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
 
$db = new ps_DB;
$db->query( "SELECT COUNT(*) AS cnt FROM #__{vm}_product p,#__{vm}_product_category_xref pc, #__{vm}_category c
            WHERE p.product_publish='Y' AND pc.product_id = p.product_id AND pc.category_id = c.category_id AND c.category_id = '$category_id' AND p.product_id != '$product_id'
            AND p.product_full_image <> '' ");
$db->next_record();
$nume = $db->f('cnt');


   $q = "SELECT p.product_id, p.product_name, p.product_thumb_image, p.product_s_desc, c.category_name, c.category_flypage
            FROM #__{vm}_product p,#__{vm}_product_category_xref pc, #__{vm}_category c
            WHERE p.product_publish='Y' AND pc.product_id = p.product_id AND pc.category_id = c.category_id AND c.category_id = '$category_id' AND p.product_id != '$product_id'
            AND p.product_full_image <> '' ORDER BY p.product_name LIMIT $eu, $limit";
   

///// Variables set for advance paging///////////
$p_limit=6; // This should be more than $limit and set to a value for whick links to be breaked

$p_f=$_GET['p_f'];                        // To take care global variable if OFF
if(!($p_f > 0)) {                         // This variable is set to zero for the first page
$p_f = 0;
}



$p_fwd=$p_f+$p_limit;
$p_back=$p_f-$p_limit;
//////////// End of variables for advance paging ///////////////
/////////////// Start the buttom links with Prev and next link with page numbers /////////////////
echo "<div style='margin-left:3px; margin-top:0px; float:inherit; display:inline;'>";
if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back' style='font-family: 'Century Gothic'; font-size:12px; color:#796e69;'>PREV</a>"; }

//echo "</td><td  align='left' width='10%'>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0 and ($back >=$p_f)) {
print "<a href='$page_name?start=$back&p_f=$p_f' style='font-family: 'Century Gothic'; font-size:12px; color:#796e69;'>PREV</a>";
}
//////////////// Let us display the page links at  center. We will not display the current page as a link ///////////
//echo "</td><td>";
for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
if($i <> $eu){
$i2=$i+$p_f;
echo " <a href='$page_name?start=$i&p_f=$p_f'>$i</a> ";
}
//else { echo "<font face='Verdana' size='4' color=red>$i</font>";}        /// Current page is not displayed as link and given font color red

}

//echo "</td><td>";
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume and $this1 <($p_f+$p_limit)) {
echo "<a href='$page_name?start=$next&p_f=$p_f' style='font-family: 'Century Gothic'; font-size:12px; color:#796e69;>NEXT</a>";
}
//echo "</td><td  align='right' width='20%'>";
if($p_fwd < $nume){
print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd' style='font-family: 'Century Gothic'; font-size:12px; color:#796e69;>NEXT</a>";
}
echo "</div><br>";


if( $db->next_record() )  {
   $flypage = $db->f('category_flypage');
   $db->reset();
   echo '<br><table width="100%" align="center" cellspacing="0px">';
   echo '<tr>';
   echo '<td>';
   while( $rs = $db->next_record() ) {
      ?>
      <a href="<?php  $sess->purl(URL . "index.php?page=shop.product_details&flypage=$flypage&product_id=" . $db->f("product_id") . "&category_id=$category_id" ) ?>">
      <img src="<?php echo $mosConfig_live_site;?>/components/com_virtuemart/shop_image/product/<?php $db->p("product_thumb_image");?>"/>
      </a>
      <?php
   echo '<td>';
   } //while
echo '<tr></table>';
} // if

?>

Can not get it work, but actually i don't need pagination, i just need to limit it, for example limit just 4 latest products to show under flypage detail. anybody can help me? thanks in advance