Author Topic: MOD: Child list instead of drop down. UPDATE(1.0.11) + store wide quantity mod  (Read 456037 times)

thomas_freeman

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 450
    • Kustom Services
Re: MOD: Child list instead of drop down. UPDATE (
« Reply #195 on: October 20, 2006, 16:34:35 pm »
Well, If you look at the current use of Product_Types, they are displayed in rows at the bottom of the page.  It comes down to replacing the <td> code in my modifications with <tr>.  Wouldn't be hard at all.

I will try to clean up my changes and post it.  It is closely tied to this mod, so I'm not sure if I should keep it in this "growing" thread or start a separate post.  I really wish there was a way to clearly indicate sub-threads within these threads.

JDA

  • Beginner
  • *
  • Posts: 17
I appreciate your help!

I look forward to seeinig the changes you have made. It seems this could be the soloution I am looking for!

As far as this thread is concerned, I'm not sure If we should continue here either. On the other hand I can imagine others are interested in expanding this mod with extra fields.

Perhaps Mark can let us know as it is his thread and mod!

Thanks,

Jesse


macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
JDA & thomas_freeman,

the best way I can see of using product type's with my mod is to set up a call to product types at the end of the child list loop within ps_product_attributes.php. This would allow product type info to be displayed with each child. Obviously using product.type flypages (which aren't flypages as with the rest of VM, they're extensions) would allow the output to be formatted as you like.

If you really need it I'll look into where it should be inserted in the code and will post the modifications. It shouldn't be that difficult.

As to setting up a separate thread for a mod to a mod I do not know if that's appropriate. I know someone has asked for this thread to be a child thread in its own right, again I don't know if its appropriate. But I will say that I am working on this mod to be integrated in VM 1.1

Mark
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

JDA

  • Beginner
  • *
  • Posts: 17
Hi Mark,

Thanks for your reply and thanks for a great mod!

If it is't to much trouble for you, I'ld really appreciate your help on this.

In my opinion it would be a great addition to be able to display the child product types.
For my situation it would be the perfect way to display all info on a music album and the individual tracks on one page. The next step for me would be to create an "audition" button which loads the product (child) download file in a mp3 player like wimpy. If I can get this all working I think this would be a great soloution for anyone selling music with VM.

I hope this mod becomes a part of VM 1.1! Thanks again for all the work you've done!

Jesse

thomas_freeman

  • Contributing Developer
  • Jr. Member
  • *
  • Posts: 450
    • Kustom Services
Here is the code I used to create the columnar product type report.

First I added two functions to the ps_product_types.php
Quote
   /**************************************************************************
   ** name: listrow_product_type_element()
   ** created by: Thomas Freeman by modifying list_product_type
   ** description: Returns html code for show parameters
   ** parameters: product_id
   ** returns:
   ***************************************************************************/
   function listrow_product_type_element($product_id) {
      global $VM_LANG, $mosConfig_live_site;

      if (!$this->product_in_product_type($product_id)) {
         return "";
         }

      $dbag = new ps_DB;
      $dba = new ps_DB;
      $dbp = new ps_DB;
      $html = "";

      $q  = "SELECT * FROM #__{vm}_product_product_type_xref ";
      $q .= "LEFT JOIN #__{vm}_product_type USING (product_type_id) ";
      $q .= "WHERE product_id='$product_id' AND product_type_publish='Y' ";
      $q .= "ORDER BY product_type_list_order";
      $dbag->query( $q );
      $q  = "SELECT * FROM #__{vm}_product_type_parameter ";
      $q .= "WHERE product_type_id=";
      while ($dbag->next_record()) { // Show all Product Type

         // SELECT parameter value of product
         $q2  = "SELECT * FROM #__{vm}_product_type_".$dbag->f("product_type_id");
         $q2 .= " WHERE product_id='$product_id'";
         $dbp->query($q2);
         
         // SELECT parameter of Product Type
         $dba->query($q.$dbag->f("product_type_id")." ORDER BY parameter_list_order");
         $i=0;
         while ($dba->next_record()) {
            $html .= "<td style=\"text-align:center\" id=\"Product_Type_Element\">";
            $html .= $dbp->f($dba->f("parameter_name"))." ".$dba->f("parameter_unit");
         }
      }
      return $html;
   }
      
   /**************************************************************************
   ** name: listrow_product_type_heading()
   ** created by: Thomas Freeman by modifying list_product_type
   ** description: Returns html code for show parameters
   ** parameters: product_id
   ** returns:
   ***************************************************************************/
   function listrow_product_type_heading($product_id) {
      global $VM_LANG, $mosConfig_live_site;

      if (!$this->product_in_product_type($product_id)) {
         return "";
         }

      $dbag = new ps_DB;
      $dba = new ps_DB;
      $dbp = new ps_DB;
      $html = "";

      $q  = "SELECT * FROM #__{vm}_product_product_type_xref ";
      $q .= "LEFT JOIN #__{vm}_product_type USING (product_type_id) ";
      $q .= "WHERE product_id='$product_id' AND product_type_publish='Y' ";
      $q .= "ORDER BY product_type_list_order";
      $dbag->query( $q );
      $q  = "SELECT * FROM #__{vm}_product_type_parameter ";
      $q .= "WHERE product_type_id=";
      while ($dbag->next_record()) { // Show all Product Type

         // SELECT parameter value of product
         $q2  = "SELECT * FROM #__{vm}_product_type_".$dbag->f("product_type_id");
         $q2 .= " WHERE product_id='$product_id'";
         $dbp->query($q2);
         
         // SELECT parameter of Product Type
         $dba->query($q.$dbag->f("product_type_id")." ORDER BY parameter_list_order");
         $i=0;
         while ($dba->next_record()) {
            $html .= "<th style=\"text-align:center\" id=\"Product_Type_Heading\">";
            $html .= $dba->f("parameter_label")."</th>";
         }
      }
      return $html;
   }
Then I modified Mark's mod in ps_poduct_attribute.php.  First I added a call to load the ps_product_type.php file where I added the functions.
Quote
   function list_attribute_list_multiple($product_id) {

      global $VM_LANG, $CURRENCY_DISPLAY,$mm_action_url,$sess;
   
      require_once (CLASSPATH . 'ps_product.php' );
      $ps_product = new ps_product;
      
      /** Load important classes **/ 
      require_once(CLASSPATH . 'ps_product_type.php' );
      $ps_product_type = new ps_product_type;

Around line 488 I added a line to show headers before  finishing the price tag:
Quote
               /** Get Product Type Heading List **/ 
               $html .= $ps_product_type->listrow_product_type_heading($db->f("product_parent_id"));
               
                    $html .= "<th>Price</th>";
Around line 537 I added the following code before the attribute list code.
Quote
            /** Get Product Type Element List **/ 
            $html .= $ps_product_type->listrow_product_type_element($db->f("product_id"));

                // For each child get attribute values by looping through attribute list
            $q = "SELECT product_id, attribute_name FROM #__{vm}_product_attribute_sku ";
            $q .= "WHERE product_id='$product_id' ORDER BY attribute_list ASC";

This will cause the product_types to be listed in columns on your flypage.  However, be aware that the product_types will also display at the bottom of the page unless you remove that call from flypage layout.  Also, the headers are dependent on the parent object having the same product type.  This meant that I needed the flypage to display differently depending on if it is showing a parent or children.  I modified the shop.product_details.php to do this.  Around line 139 I added to lines to show if children are present:
Quote
/** Get the CATEGORY NAVIGATION **/
  $navigation_pathway = "";
  $navigation_childlist = "";
  $pathway_appended = false;
  /** PTMOD - show no children are present **/ 
  $children_present = false;
  if (empty($category_id))  {
  /** PTMOD - show children ARE present **/ 
     $children_present = true;
Then I modified the string replacements around line 465 to conditionally display the product_type Data:
Quote
/** NOW LET'S BEGIN AND FILL THE TEMPLATE **/
$template = str_replace( "{navigation_pathway}", $navigation_pathway, $template );
$template = str_replace( "{navigation_childlist}", $navigation_childlist, $template );
$template = str_replace( "{product_name}", $product_name, $template );
$template = str_replace( "{file_list}", $file_list, $template );
$template = str_replace( "{edit_link}", $edit_link, $template );
$template = str_replace( "{manufacturer_link}", $manufacturer_link, $template );
$template = str_replace( "{product_s_desc}", $db_product->f("product_s_desc"), $template );
$template = str_replace( "{product_description}", $product_description, $template );
$template = str_replace( "{product_weight}", $db_product->f("product_weight"), $template );
$template = str_replace( "{product_sku}", $db_product->f("product_sku"), $template );
$template = str_replace( "{addtocart}", $addtocart, $template );
$template = str_replace( "{product_reviews}", $product_reviews, $template );
$template = str_replace( "{product_reviewform}", $product_reviewform, $template );
$template = str_replace( "{product_availability}", $product_availability, $template );
$template = str_replace( "{vendor_link}", $vendor_link, $template );
$template = str_replace( "{mosConfig_live_site}", $mosConfig_live_site, $template );
$template = str_replace( "{related_products}", $related_product_html, $template );
$template = str_replace( "{product_packaging}", $product_packaging, $template ); // Changed Packaging

/** PTMOD - Only replace these if there are no children present. **/ 
if ($children_present != False){
   $template = str_replace( "{product_image}", "", $template );
   $template = str_replace( "{full_image}", $full_image, $template ); // to display the full image on flypage
   $template = str_replace( "{more_images}", $more_images, $template );
   $template = str_replace( "{product_price}", $product_price, $template );
   $template = str_replace( "{product_type}", $product_type, $template ); // Changed Product Type
   }
   else {
      $template = str_replace( "{product_image}", "", $template );
      $template = str_replace( "{full_image}", "", $template ); // to display the full image on flypage
      $template = str_replace( "{more_images}", "", $template );
      $template = str_replace( "{product_price}", "", $template );
      $template = str_replace( "{product_type}", "", $template ); // Changed Product Type
}


I know this is not the most elegant or cleanest code.  I would love to have someone clean it up and pass it on.

Enjoy!

JDA

  • Beginner
  • *
  • Posts: 17
Thanks for sharing this! I added your code and all seems to work!

Now I will add the proper data and figure out how to display the info like I want it to. I will let you know how things progres!

As for the code, it is far more than I could have achieved! Hopefully someone is willing to take a closer look at it, it's definitly a great add on to this mod!

Thanks again,

Jesse

JDA

  • Beginner
  • *
  • Posts: 17
Having spent the better part of two days trying to display the child product type attributes as I would like, I still havn't made much progres...

In ps_product_types.php I added some code to the function Thomas pasted earlier to call for a product_type flypage:
Quote
   /**************************************************************************
   ** name: listrow_product_type_element()
   ** created by: Thomas Freeman by modifying list_product_type
   ** description: Returns html code for show parameters
   ** parameters: product_id
   ** returns:
   ***************************************************************************/
   function listrow_product_type_element($product_id) {
      global $VM_LANG, $mosConfig_live_site;

      if (!$this->product_in_product_type($product_id)) {
         return "";
         }

      $dbag = new ps_DB;
      $dba = new ps_DB;
      $dbp = new ps_DB;
      $html = "";

      $q  = "SELECT * FROM #__{vm}_product_product_type_xref ";
      $q .= "LEFT JOIN #__{vm}_product_type USING (product_type_id) ";
      $q .= "WHERE product_id='$product_id' AND product_type_publish='Y' ";
      $q .= "ORDER BY product_type_list_order";
      $dbag->query( $q );
      $q  = "SELECT * FROM #__{vm}_product_type_parameter ";
      $q .= "WHERE product_type_id=";
      while ($dbag->next_record()) { // Show all Product Type
         if ($dbag->f("product_type_flypage")) {
            $flypage_file = PAGEPATH."templates/".$dbag->f("product_type_flypage").".php";
            if (file_exists($flypage_file)) {
               $html .= include($flypage_file);
               continue;
            }
         }

         // SELECT parameter value of product
         $q2  = "SELECT * FROM #__{vm}_product_type_".$dbag->f("product_type_id");
         $q2 .= " WHERE product_id='$product_id'";
         $dbp->query($q2);
         
         // SELECT parameter of Product Type
         $dba->query($q.$dbag->f("product_type_id")." ORDER BY parameter_list_order");
         $i=0;
         while ($dba->next_record()) {
            $html .= "<td style=\"text-align:center\" id=\"Product_Type_Element\">";
            $html .= $dbp->f($dba->f("parameter_name"))." ".$dba->f("parameter_unit");
         }
      }
      return $html;
   }

This seems to work fine and I made a product_type flypage based on a post by macallf elsewhere in the forum:
Quote
<?php
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
*
* @package VirtueMart
* @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.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName( __FILE__ );

Global $perm;

//if(!$standard)
//    return "";

   
            $html1 = "\n<table id=\"product_type\" class=\"product_type\" width=\"100%\" cellspacing=\"2\" cellpadding=\"0\" border=\"0\" >\n";
         // SELECT parameter value of product
         $q2  = "SELECT * FROM #__{vm}_product_type_".$dbag->f("product_type_id");
         $q2 .= " WHERE product_id='$product_id'";
         $dbp->query($q2);
         // SELECT parameter of Product Type
         $dba->query($q.$dbag->f("product_type_id")." ORDER BY parameter_list_order");
         $i=0;
         while ($dba->next_record()) {
                $label = $dba->f("parameter_label");
                //Check for store admin if not dont show these fields
                //if (!$perm->check("admin,storeadmin")) {
                //    if ($label == "Film No." || $label == "Frame No." || $label == "Full Image File Name" )
                //    continue;
                //}
                    if ($i++ % 2)
                    $bgcolor=SEARCH_COLOR_1;
                else
                    $bgcolor=SEARCH_COLOR_2;
                $html1 .= "<tr  bgcolor=\"$bgcolor\" height=\"18\">\n";
                $html1 .= "<td  width=\"50%\">&nbsp;".$label;
                $parameter_description = $dba->f("parameter_description");
                if (!empty($parameter_description)) {
                   $html1 .= "&nbsp;";
                   $html1 .= mm_ToolTip($parameter_description, $VM_LANG->_PHPSHOP_PRODUCT_TYPE_PARAMETER_FORM_DESCRIPTION);
                }
                $html1 .= "</td>\n<td  >&nbsp;";
                    $param_name = $dbp->f($dba->f("parameter_name"));
                $html1 .= $param_name." ".$dba->f("parameter_unit")."</td></tr>\n";
               
         }
         $html1 .= "</table>\n";
           
            return $html1;
           
?>

Having studied the above code (with my lack of PHP knowledge) I think I know how to place the $lable and $param_name variables in a table using $htmll. The problem is that I don't know hoe to call the product type attributes ($lable and $param_name) individually in order to place them in the tablecells where they belong. Í hope I am making sense at all as I am new to all of this...

Would someone be willing to help me out on this? I have added an image of what I would like to achieve...
Any help would greatly be appreciated!

Thanks in advance,

Jesse

[attachment cleanup by admin]

dazzzl12

  • Beginner
  • *
  • Posts: 2
Re: MOD: Child list instead of drop down. UPDATE (
« Reply #202 on: October 31, 2006, 22:31:23 pm »
Hi,

i`m a relative beginner with vm and read the whole thread about this nice modification.
but i cant understand all things you`ve written. my english is to poor for this
please can anyone make a post with a FINAL .zip???
best a .zip like this JPG: ex_album_display.jpg
thanks....


macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Hi,

i`m a relative beginner with vm and read the whole thread about this nice modification.
but i cant understand all things you`ve written. my english is to poor for this
please can anyone make a post with a FINAL .zip???
best a .zip like this JPG: ex_album_display.jpg


The latest full version is attached below.

This does not include the mod as in the image you state.

This is not a modification that I've made, so I have not tested it and cannot guarantee its functionality. There fore I cannot support it.

To Install unzip into your-site/administrator/components/com_virtuemart/  (Where your-site is the root of your joomla install)

It will overwrite several files SO BACKUP YOUR FILES FIRST

Mark

[attachment cleanup by admin]
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

kooolkat357

  • Beginner
  • *
  • Posts: 13
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #204 on: November 07, 2006, 09:50:09 am »
Hi!

After i installed your mod my layout get messed up. Before install the boxes were lined up vertically and now they are horisontally.

Can you please help with this problem?

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #205 on: November 07, 2006, 14:29:03 pm »
Which boxes?

A link to your site or a screenshot would help

Mark
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

kooolkat357

  • Beginner
  • *
  • Posts: 13
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #206 on: November 07, 2006, 15:25:39 pm »
Hi!

You can look at it here: http://www.mobileksperten.com/butikk/butikk/postal-unlock_10/sony_ericsson_unlock_18.html

Sorry for not inserting it in the last post.

macallf

  • Full Member
  • ***
  • Posts: 2411
    • Mark Callf Design
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #207 on: November 07, 2006, 16:21:38 pm »
Thats what I thought.

the reason for that is if you are listing several children with attributes the page soon fills up.

So I changed it so that the attributes are listed in a row.

If you edit ps_product_attribute.php and search for this code, which is in function list_advanced_attribute about line 687.

$html .= "<td align=\"right\" valign=\"middle\">";
$html .= "<label for=\"".$titlevar."_field\">$title</label>:";

and replace it with this code

$html .= "<div style=\"width:30%;float:left;text-align:right;margin:3px;\">";
$html .= "<label for=\"".$titlevar."_field\">$title</label>:</div>";
$html .= "<div style=\"width:60%;float:left;margin:3px;\">";

further down you'll find this code

$html.="</select></span></td>\n";

replace with this

$html.="</select></span></div>\n";

that will restore the original layout, but keep the child list.

Mark
Mark
All of My old mods are now available on my website.
Mark Callf Designs

If you like the work I've done for VM please fell free to Donate

Please Note: I am no longer actively developing or involved with VM development.

kooolkat357

  • Beginner
  • *
  • Posts: 13
Re: MOD: Child list instead of drop down. UPDATE (
« Reply #208 on: November 07, 2006, 17:20:38 pm »
Greeeat, now it's like it should be....

Thx

Kooolkat357

mark R

  • Jr. Member
  • **
  • Posts: 220
Re: MOD: Child list instead of drop down. UPDATE (1.0.6) + store wide quantity m
« Reply #209 on: November 10, 2006, 22:45:01 pm »
Hi all,

Would it be possible to get the available QTY, to display in the child list??

thanks in advance

Mark
Seek and ye shall find.........
4 VM sites and counting