X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Extra Fields as Pop Ups (https://forum.x-cart.com/showthread.php?t=61702)

DrQuietus 11-19-2011 06:43 AM

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.

gtwing 11-29-2011 09:45 PM

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.

klinetim 11-30-2011 05:21 AM

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.

cflsystems 11-30-2011 06:24 AM

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


All times are GMT -8. The time now is 05:39 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.