GeordiSi Posted August 29, 2006 Share Posted August 29, 2006 Hi I took a post (I forget from who) and modified the code so that I can capture the product extra fields information into variables that can be displayed in the Simple Template System. I pasted this into the product_info.php script. // START: Extra Fields Contribution v2.0b $extra_fields_query = tep_db_query("SELECT pef.products_extra_fields_status as status, pef.products_extra_fields_name as name, ptf.products_extra_fields_value as value FROM ". TABLE_PRODUCTS_EXTRA_FIELDS ." pef LEFT JOIN ". TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS ." ptf ON ptf.products_extra_fields_id=pef.products_extra_fields_id WHERE ptf.products_id=".$HTTP_GET_VARS['products_id']." and ptf.products_extra_fields_value<>'' and (pef.languages_id='0' or pef.languages_id='".$languages_id."') and (products_extra_fields_order='1')"); $counter = tep_db_num_rows($extra_fields_query); if($counter > 0){ while($extra_fields = tep_db_fetch_array($extra_fields_query)) { if(!$extra_fields['status']) // show only enabled extra field continue; $template_pinfo['product_extra_field_name1'] = '<b>'.$extra_fields['name'].': </b>'; $template_pinfo['product_extra_field_value1'] = $extra_fields['value'].'<br>'; } } else { $template_pinfo['product_extra_field_name1'] = ''; $template_pinfo['product_extra_field_value1'] = ''; } // END: Extra Fields Contribution Obviously changing 1 to 2 etc will produce variables for each of the fields. I'm very new to PHP but I can see that this approach will be quite clumsy (I also recognise that the count lines are not necessary). I would like to setup a loop which automatically generates ALL of the field variables (1,2,3 etc) for any number of fields. I can see how to set up the variables $template_pinfo['product_extra_field_name1'.$fieldnum] = '<b>'.$extra_fields['name'].': </b>'; would do that. BUT. I cannot seem to build a loop that works. Any suggestions would be welcome as I think that this would be an extremely useful contribution when finished. Many thanks. Quote Link to comment Share on other sites More sharing options...
bkellum Posted October 16, 2006 Share Posted October 16, 2006 HiI took a post (I forget from who) and modified the code so that I can capture the product extra fields information into variables that can be displayed in the Simple Template System. I pasted this into the product_info.php script. // START: Extra Fields Contribution v2.0b $extra_fields_query = tep_db_query("SELECT pef.products_extra_fields_status as status, pef.products_extra_fields_name as name, ptf.products_extra_fields_value as value FROM ". TABLE_PRODUCTS_EXTRA_FIELDS ." pef LEFT JOIN ". TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS ." ptf ON ptf.products_extra_fields_id=pef.products_extra_fields_id WHERE ptf.products_id=".$HTTP_GET_VARS['products_id']." and ptf.products_extra_fields_value<>'' and (pef.languages_id='0' or pef.languages_id='".$languages_id."') and (products_extra_fields_order='1')"); $counter = tep_db_num_rows($extra_fields_query); if($counter > 0){ while($extra_fields = tep_db_fetch_array($extra_fields_query)) { if(!$extra_fields['status']) // show only enabled extra field continue; $template_pinfo['product_extra_field_name1'] = '<b>'.$extra_fields['name'].': </b>'; $template_pinfo['product_extra_field_value1'] = $extra_fields['value'].'<br>'; } } else { $template_pinfo['product_extra_field_name1'] = ''; $template_pinfo['product_extra_field_value1'] = ''; } // END: Extra Fields Contribution Obviously changing 1 to 2 etc will produce variables for each of the fields. I'm very new to PHP but I can see that this approach will be quite clumsy (I also recognise that the count lines are not necessary). I would like to setup a loop which automatically generates ALL of the field variables (1,2,3 etc) for any number of fields. I can see how to set up the variables $template_pinfo['product_extra_field_name1'.$fieldnum] = '<b>'.$extra_fields['name'].': </b>'; would do that. BUT. I cannot seem to build a loop that works. Any suggestions would be welcome as I think that this would be an extremely useful contribution when finished. Many thanks. Which version of STS are you using? Quote Bill Kellum Sounds Good Productions STS Tutorials & more: STSv4.6, STS Add-ons (STS Power Pack), STS V4 Forum STS Forum FREE TEMPLATE Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.