Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Easily add Static Page (FAQ) Link on Products

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 03-15-2005, 07:48 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default Easily add Static Page (FAQ) Link on Products

Some old code laying around, decided I would release it. This was done on 3.5.x so it may need revamping for 4.0.x.

This mod will give you a drop down list of all static pages on modify product pages so that you can easily select them and associate them.

Use the below SQL in patch/upgrade to add the additional faq field:
Code:
ALTER TABLE `xcart_products` ADD `faq` INT( 11 ) NOT NULL ;

Edit, include/product_modify.php
Code:
# # Add pages array for dropdown # $pages = func_query("SELECT * from `xcart_pages` ORDER BY orderby"); $smarty->assign("pages",$pages);

You'll also need to update the db query so comment out the similar line and add this one instead.
Code:
# # Find the similar db query and update accordingly # , faq='$faq' # is appended to the query # db_query("update $sql_tbl[products] set preorder='$preorder', product='$product', categoryid='$categoryid', categoryid1='$categoryid1', categoryid2='$categoryid2', categoryid3='$categoryid3', categoryid4='$categoryid4', categoryid5='$categoryid5', categoryid6='$categoryid6', categoryid7='$categoryid7', categoryid8='$categoryid8', categoryid9='$categoryid9', categoryid10='$categoryid10', brand='$brand', model='$model', keywords='$keywords', descr='$descr', fulldescr='$fulldescr', avail='$avail', list_price='$list_price', weight='$weight', productcode='$productcode', forsale='$forsale', distribution='$distribution', free_shipping='$free_shipping', shipping_freight='$shipping_freight', discount_avail='$discount_avail', min_amount='$min_amount', param00='$param00', param01='$param01', param02='$param02', param03='$param03', param04='$param04', param05='$param05', param06='$param06', param07='$param07', param08='$param08', param09='$param09', param10='$param10', param11='$param11', param12='$param12', param13='$param13', faq='$faq', low_avail_limit='$low_avail_limit', $apply_vat free_tax='$free_tax' $apply_canadian_taxes where productid='$productid'");

Now edit, skin1/main/product_modify.tpl and add:

Code:
# # Cart-Lab.com FAQ link # <TR> <TD class=ProductDetails>FAQ Page</TD> <TD class=ProductDetails> <SELECT name="faq"> <OPTION value=0 {if $product.faq eq "0"}selected{/if}>{$lng.lbl_undefined}</OPTION> {section name=num loop=$pages} <OPTION value="{$pages[num].pageid}" {if $pages[num].pageid eq $product.faq}selected{/if}>{ $pages[num].title}</OPTION> {/section} </SELECT> </TD> </TR>

You'll also need add a link in your product.tpl page that calls the link, like so:

Code:

Happy X-Carting!
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #2  
Old 03-23-2005, 08:18 AM
 
Sascha78 Sascha78 is offline
 

Newbie
  
Join Date: Mar 2005
Posts: 4
 

Default Adding dropdown to product table

Iб╢m trying to add a dropdown list to the products table. What Iб╢ve done is pretty the same you did with the FAQ page.

Code:
ALTER TABLE `xcart_products` ADD `prod_type` INT( 11 ) NOT NULL ;



include/product_modify.php


Code:
$prod_type = func_query("SELECT $sql_tbl[products].prod_type FROM $sql_tbl[products]"); $smarty->assign("prod_type", $prod_type);

Updated the database query

Code:
db_query("UPDATE $sql_tbl[products] SET product='$product', descr='$descr', fulldescr='$fulldescr', avail='$avail', list_price='$list_price', weight='$weight', productcode='$productcode', forsale='$forsale', distribution='$distribution', free_shipping='$free_shipping', shipping_freight='$shipping_freight', discount_avail='$discount_avail', min_amount='$min_amount', return_time = '$return_time', prod_type='$prod_type', low_avail_limit='$low_avail_limit', free_tax='$free_tax' WHERE productid='$productid'");

But then I edited skin1/main/product_details.tpl

Code:
<TR> {if $productids ne ''}<TD width="15" class="TableSubHead"><INPUT type="checkbox" value="Y" name="fields[prod_type]"></TD>{/if} <TD class="FormButton" nowrap>{$lng.lbl_type}:</TD> <TD class="ProductDetails"> <SELECT name="type"> <OPTION value="U" {if $product.prod_type eq "U"}selected{/if}>{$lng.lbl_used}</OPTION> <OPTION value="N" {if $product.prod_type eq "N"}selected{/if}>{$lng.lbl_new}</OPTION> <OPTION value="R" {if $product.prod_type eq "R"}selected{/if}>{$lng.lbl_reman}</OPTION> </SELECT> </TD> </TR>

After that I included the new field in the product skin1/customer/main/product.tpl

Code:
{$lng.lbl_type}: {$products[product].prod_type}

It all looks fine. But it seems that there is something wrong with the database query. I get the option fields while adding a product but it shows only a "O" on the customer front-end product page.

Any help would be highly appreciated.
__________________
Xcart Pro Version 4.0.12
Reply With Quote
  #3  
Old 05-02-2005, 11:11 AM
  RQJay's Avatar 
RQJay RQJay is offline
 

Senior Member
  
Join Date: Oct 2004
Posts: 185
 

Default Re: Easily add Static Page (FAQ) Link on Products

Any one know if this will work on 4.0x??

Quote:
Originally Posted by B00MER
Some old code laying around, decided I would release it. This was done on 3.5.x so it may need revamping for 4.0.x.

This mod will give you a drop down list of all static pages on modify product pages so that you can easily select them and associate them.

Use the below SQL in patch/upgrade to add the additional faq field:
Code:
ALTER TABLE `xcart_products` ADD `faq` INT( 11 ) NOT NULL ;

Edit, include/product_modify.php
Code:
# # Add pages array for dropdown # $pages = func_query("SELECT * from `xcart_pages` ORDER BY orderby"); $smarty->assign("pages",$pages);

You'll also need to update the db query so comment out the similar line and add this one instead.
Code:
# # Find the similar db query and update accordingly # , faq='$faq' # is appended to the query # db_query("update $sql_tbl[products] set preorder='$preorder', product='$product', categoryid='$categoryid', categoryid1='$categoryid1', categoryid2='$categoryid2', categoryid3='$categoryid3', categoryid4='$categoryid4', categoryid5='$categoryid5', categoryid6='$categoryid6', categoryid7='$categoryid7', categoryid8='$categoryid8', categoryid9='$categoryid9', categoryid10='$categoryid10', brand='$brand', model='$model', keywords='$keywords', descr='$descr', fulldescr='$fulldescr', avail='$avail', list_price='$list_price', weight='$weight', productcode='$productcode', forsale='$forsale', distribution='$distribution', free_shipping='$free_shipping', shipping_freight='$shipping_freight', discount_avail='$discount_avail', min_amount='$min_amount', param00='$param00', param01='$param01', param02='$param02', param03='$param03', param04='$param04', param05='$param05', param06='$param06', param07='$param07', param08='$param08', param09='$param09', param10='$param10', param11='$param11', param12='$param12', param13='$param13', faq='$faq', low_avail_limit='$low_avail_limit', $apply_vat free_tax='$free_tax' $apply_canadian_taxes where productid='$productid'");

Now edit, skin1/main/product_modify.tpl and add:

Code:
# # Cart-Lab.com FAQ link # <TR> <TD class=ProductDetails>FAQ Page</TD> <TD class=ProductDetails> <SELECT name="faq"> <OPTION value=0 {if $product.faq eq "0"}selected{/if}>{$lng.lbl_undefined}</OPTION> {section name=num loop=$pages} <OPTION value="{$pages[num].pageid}" {if $pages[num].pageid eq $product.faq}selected{/if}>{ $pages[num].title}</OPTION> {/section} </SELECT> </TD> </TR>

You'll also need add a link in your product.tpl page that calls the link, like so:

Code:

Happy X-Carting!
Reply With Quote
  #4  
Old 05-02-2005, 11:27 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Yes, but you'll need to re-edit the dbquery as the SQL query is different in 4.0.x.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #5  
Old 12-07-2005, 11:00 PM
 
Lionel Lionel is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 199
 

Default

I did everything in this hack and it works fine as designed.
But instead of using the generic FAQ name, I wanted to use the page title.
I already added a field in database for it. The question is (I am new to smarty), how do I get that $pages[num].title?



Code:
<SELECT name="faq"> <OPTION value=0 {if $product.faq eq "0"}selected{/if}>{$lng.lbl_undefined}</OPTION> {section name=num loop=$pages} <OPTION value="{$pages[num].pageid}" {if $pages[num].pageid eq $product.faq}selected{/if}>{ $pages[num].title}</OPTION> {/section} </SELECT>

Something like

Code:
<input type="hidden" name="title" value="{ $pages[num].title}">

Any help is greatly appreciated. Thank you
__________________
X-Cart Gold 4.0.17 [unix]
X-Cart Gold 4.0.18 [unix]
Reply With Quote
  #6  
Old 03-10-2006, 04:31 PM
 
Lionel Lionel is offline
 

Senior Member
  
Join Date: Dec 2005
Posts: 199
 

Default

I improved this a little, so

1-It displays the title of the FAQ instead of 'Product FAQ'

2-It will display only if there are FAQ for the product

in product.php towards the end, before
Code:
$smarty->assign("product",$product_info);

I added:

Code:
if ($product_info['faq'] !='0'){ $faqtitle=db_query("SELECT title from xcart_pages WHERE pageid='$product_info[faq]'"); $mytitle=db_result($faqtitle,"title"); $smarty->assign("mytitle",$mytitle); }

and in skin1/customer/main/product.tpl

Code:
{if $product.faq ne '0'}<TR><TD>Additional data: </td><td><A HREF="pages.php?pageid={$product.faq}" target="_BLANK">{$mytitle} </A></td></tr>{/if}
__________________
X-Cart Gold 4.0.17 [unix]
X-Cart Gold 4.0.18 [unix]
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 04:22 AM.

   

 
X-Cart forums © 2001-2020