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

Extra Fields as Pop Ups

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-19-2011, 06:43 AM
  DrQuietus's Avatar 
DrQuietus DrQuietus is offline
 

Advanced Member
  
Join Date: Dec 2005
Posts: 81
 

Default Extra Fields as Pop Ups

I was working on this for a while and thought someone else might want to use it or improve it.

Instead of calling all the extra fields in the product details the customer wanted links to each extra field which, when clicked, opened in a popup box like the "ask a question about this product" link.

here is what I did:

1. made a new file in the root called popup_ef.php
Code:
<?php require './auth.php'; /** * Get productid */ $productid = intval($productid); if ( empty($productid) ) { func_close_window(); } x_load('product'); $product = func_select_product($productid, $user_account['membershipid']); if ( empty($product) ) { func_close_window(); } if ($productid) { $extra_fields = func_query("SELECT $sql_tbl[extra_fields].*, $sql_tbl[extra_field_values].value as field_value, IF($sql_tbl[extra_field_values].fieldid > '0', 'Y', '') as is_value, IF($sql_tbl[extra_fields_lng].field != '', $sql_tbl[extra_fields_lng].field, $sql_tbl[extra_fields].field) as field FROM $sql_tbl[extra_fields] LEFT JOIN $sql_tbl[extra_field_values] ON $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_field_values].fieldid AND $sql_tbl[extra_field_values].productid = '$productid' LEFT JOIN $sql_tbl[extra_fields_lng] ON $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_fields_lng].fieldid AND $sql_tbl[extra_fields_lng].code = '$shop_language' WHERE 1 $provider_condition ORDER BY $sql_tbl[extra_fields].orderby"); } else { $extra_fields = func_query("SELECT $sql_tbl[extra_fields].*, IF($sql_tbl[extra_fields_lng].field != '', $sql_tbl[extra_fields_lng].field, $sql_tbl[extra_fields].field) as field FROM $sql_tbl[extra_fields] LEFT JOIN $sql_tbl[extra_fields_lng] ON $sql_tbl[extra_fields].fieldid = $sql_tbl[extra_fields_lng].fieldid AND $sql_tbl[extra_fields_lng].code = '$shop_language' WHERE 1 $provider_condition ORDER BY $sql_tbl[extra_fields].orderby"); } if (!empty($extra_fields)) { if (in_array(AREA_TYPE, array('C', 'B')) && $config["Extra_Fields"]["display_default_extra_fields"] == 'Y') { foreach ($extra_fields as $ef_k=>$ef_v) { if (empty($ef_v['field_value']) && $ef_v['is_value'] != 'Y' && !empty($ef_v['value'])) $extra_fields[$ef_k]['field_value'] = $ef_v['value']; } } if (in_array(AREA_TYPE, array('C', 'B')) && !$product_info["allow_active_content"]) { foreach ($extra_fields as $k => $v) { $extra_fields[$k]['field_value'] = func_xss_free($v['field_value']); } } $smarty->assign('extra_fields', $extra_fields); } $smarty->assign('foo', $foo); $smarty->assign('productid', $productid); $smarty->assign('template_name', 'modules/Extra_Fields/extra_fields_popup.tpl'); func_display('customer/help/popup_info.tpl', $smarty); ?>

2. in skin/common_files/modules/Extra_Fields made a new file called
extra_fields_popup.tpl
Code:
<table class="ef"> {foreach from=$extra_fields item=v} {if $v.active eq "Y" and $v.field_value and $v.fieldid eq $foo} <div class="property-name">{$v.field}</div> <div class="property-value">{$v.field_value}</div> {/if} {/foreach} </table>

3. changed modules/Extra_Fields/product.tpl

from

Code:
{foreach from=$extra_fields item=v} {if $v.active eq "Y" and $v.field_value} <tr> <td class="property-name">{$v.field}</td> <td class="property-value" colspan="2">{$v.field_value}</td> </tr> {/if} {/foreach}

to


Code:
{foreach from=$extra_fields item=v} {if $v.active eq "Y" and $v.field_value} {include file="customer/buttons/button.tpl" button_title=$v.field style="button" href="javascript: return !popupOpen(xcart_web_dir + '/popup_ef.php?productid=`$product.productid`&foo=`$v.fieldid`')"} {/if} {/foreach}

Any thoughts or ideas for improvement would be greatly appreciated. I am not sure I did this the best way, but it is working.

I would also like the product title and extra field name at the top of the popup window, but haven't been able to figure it out.
__________________
Dave Jones
dave@industrialwebworks.net
Mostly 4.7.2 - 4.7.5
Reply With Quote

The following 2 users thank DrQuietus for this useful post:
gtwing (11-30-2011), proboscidian (11-19-2011)
  #2  
Old 11-29-2011, 09:45 PM
  gtwing's Avatar 
gtwing gtwing is offline
 

Advanced Member
  
Join Date: Jan 2006
Location: Running Springs, CA
Posts: 66
 

Default Re: Extra Fields as Pop Ups

Installed the mod on my 4.4.4 test store with no problems. One thing I noticed is that if you put a long line of text into the extra field the pop up box extends past the top header of the box.

Is there anyway to implement a scroll bar or set the box dimensions to prevent this?

Here's the link: http://eaglemtnoutfitters.com/test/product.php?productid=17753&cat=&page=1

Click on the Details button.
__________________
Gary M. Twing
Eagle Mountain Outfitters
eaglemtnoutfitters.com
Version 4.3.0 Gold
4.4.4 in operibus
Reply With Quote
  #3  
Old 11-30-2011, 05:21 AM
 
klinetim klinetim is offline
 

Advanced Member
  
Join Date: Oct 2011
Posts: 58
 

Default Re: Extra Fields as Pop Ups

Quote:
Installed the mod on my 4.4.4 test store with no problems. One thing I noticed is that if you put a long line of text into the extra field the pop up box extends past the top header of the box.

I noticed on your test product details popup that in IE 9, the text is displayed in a long vertical line, while in Firefox, it looks fine. Any idea on why that would be? Nice site, by the way.
__________________
Tim @ K-Line
X-Cart Version 4.4.5
http://klineind.com
Reply With Quote

The following user thanks klinetim for this useful post:
gtwing (11-30-2011)
  #4  
Old 11-30-2011, 06:24 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,192
 

Default Re: Extra Fields as Pop Ups

Quote:
Originally Posted by gtwing
Installed the mod on my 4.4.4 test store with no problems. One thing I noticed is that if you put a long line of text into the extra field the pop up box extends past the top header of the box.

Is there anyway to implement a scroll bar or set the box dimensions to prevent this?

Here's the link: http://eaglemtnoutfitters.com/test/product.php?productid=17753&cat=&page=1

Click on the Details button.

First of all you have something unclosed there or html not properly coded. In IE there is a table and the div title and text are in it, but no tr's or td's, in FF the divs are outside that table.
Try applying width to the text div or p tag
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
gtwing (11-30-2011)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 12:54 AM.

   

 
X-Cart forums © 2001-2020