Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Adding custom data to search results

Adding custom data to search results

Views: 1,818

Results 1 to 13 of 13
20 Sep 2013, 2:00 PM
#1
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Adding custom data to search results

Hello, I'm trying to add extra info to the products name section of the search result.

I've added new columns to the products_description table and would like to be able to call these columns and show this relevant data from them below the products name in the search results....

I can't figure out how to get the listing results to pull the data from these extra columns.

Any help would be greatly appreciated.

21 Sep 2013, 8:47 AM
#3
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Adding custom data to search results

I'm trying to add

<h3 class="itemTitleES">Also Found In: <a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '"><strong>' . $listing->fields['products_also_found_in_1'] . '<strong></a></h3>

into the code in file modules/MYTEMPLATE/product_listing.php

around this point

        case 'PRODUCT_LIST_NAME':
          $lc_align = '';
          if (isset($_GET['manufacturers_id'])) {
            $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
          } else {
            $lc_text = '<h2 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h2>
<h3 class="itemTitleES">EasySearch ID: <a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '"><strong>ES' . $listing->fields['products_id'] . '<strong></a></h3>
<h3 class="itemTitleES">Also Found In: <a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '"><strong>' . $listing->fields['products_also_found_in_1'] . '<strong></a></h3>
<div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
          }
          break;

Where do i need to add the calls to pd.also_found_in_1? Does it go in the header.php for advanced search result? or somewhere else?

21 Sep 2013, 2:43 PM
#4
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Adding custom data to search results

I've added new columns to the products_description table
You did not state what these are.... maybe you should add them to the "products" table

21 Sep 2013, 4:17 PM
#5
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Adding custom data to search results

as i'm pulling the products_name from the same table, i thought it would be easy to grab other columns from the same table.

23 Sep 2013, 12:10 PM
#6
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Adding custom data to search results

Anyone, surely this is simple, I've added custom fields to almost every other page, but I can't figure out how to do the search results page.

24 Sep 2013, 10:44 AM
#7
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Adding custom data to search results

Is there no one who can help?

I can't figure out which file I need to edit so i can call these tables from the search results page.

Please...

24 Sep 2013, 2:54 PM
#8
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Adding custom data to search results

DigitalShadow:

Is there no one who can help?

I can't figure out which file I need to edit so i can call these tables from the search results page.

Please...

I have posted code to add addition fields to almost every page within ZC, the product_listing page is a little tricky but very doable. Take a look at this thread.

24 Sep 2013, 4:27 PM
#9
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Adding custom data to search results

also needed to modify advanced_search_result/header_php.php

but it is done now, thankyou!

26 Sep 2013, 9:21 AM
#10
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Adding custom data to search results

One question in product_listing.php I would like to put an if statement, this is my current code and it works fine. However, I only want it to display the Part Also Found In text if the table also_found_in_1 is populated.

case 'PRODUCT_LIST_NAME':
          $lc_align = '';
          if (isset($_GET['manufacturers_id'])) {
            $lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
          } else {
            $lc_text = '<h2 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h2>
<h3 class="itemTitleES">EasySearch ID: <a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '"><strong>ES' . $listing->fields['products_id'] . '<strong></a></h3>
<h3 class="itemTitleAFI">Part Also Found In: ' . $listing->fields['also_found_in_1'] . ' ' . $listing->fields['also_found_in_2'] . ' ' . $listing->fields['also_found_in_3'] . ' ' . $listing->fields['also_found_in_4'] . ' ' . $listing->fields['also_found_in_5'] . ' ' . $listing->fields['also_found_in_6'] . ' ' . $listing->fields['also_found_in_7'] . ' ' . $listing->fields['also_found_in_8'] . ' ' . $listing->fields['also_found_in_9'] . ' ' . $listing->fields['also_found_in_10'] . ' ' . $listing->fields['also_found_in_11'] . ' ' . $listing->fields['also_found_in_12'] . ' ' . $listing->fields['also_found_in_13'] . ' ' . $listing->fields['also_found_in_14'] . ' ' . $listing->fields['also_found_in_15'] . ' ' . $listing->fields['also_found_in_16'] . ' ' . $listing->fields['also_found_in_17'] . ' ' . $listing->fields['also_found_in_18'] . ' ' . $listing->fields['also_found_in_19'] . ' ' . $listing->fields['also_found_in_20'] . ' ' . $listing->fields['also_found_in_21'] . ' </h3>
<div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
          }
          break;

Elsewhere on the website I have used this code

<?php if (empty($also_found_in_1)) { echo ''; } else { echo 'Please note that this part has also been fitted to these alternative TV models:<div id="also_found">'; } ?>

How could I modify that so it works on the search results page.

29 Sep 2013, 9:04 AM
#11
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Adding custom data to search results

Anyone?

4 Oct 2013, 6:48 AM
#12
rbarbour avatar

rbarbour

Totally Zenned

Join Date:
Feb 2010
Posts:
2,159
Plugin Contributions:
10

Re: Adding custom data to search results

DigitalShadow:

One question in product_listing.php I would like to put an if statement, this is my current code and it works fine. However, I only want it to display the Part Also Found In text if the table also_found_in_1 is populated.

case 'PRODUCT_LIST_NAME':
$lc_align = '';
if (isset($_GET['manufacturers_id'])) {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h3><div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>' ;
} else {
$lc_text = '<h2 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '">' . $listing->fields['products_name'] . '</a></h2>

<h3 class="itemTitleES">EasySearch ID: <a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), ($_GET['cPath'] > 0 ? 'cPath=' . $_GET['cPath'] . '&' : '') . 'products_id=' . $listing->fields['products_id']) . '"><strong>ES' . $listing->fields['products_id'] . '<[B]/[/B]strong></a></h3>[B]';[/B]

[B]if (zen_not_null($listing->fields['also_found_in_1'])) {[/B]

[B]$lc_text .= '[/B]<h3 class="itemTitleAFI">Part Also Found In: ' . $listing->fields['also_found_in_1'] . ' ' . $listing->fields['also_found_in_2'] . ' ' . $listing->fields['also_found_in_3'] . ' ' . $listing->fields['also_found_in_4'] . ' ' . $listing->fields['also_found_in_5'] . ' ' . $listing->fields['also_found_in_6'] . ' ' . $listing->fields['also_found_in_7'] . ' ' . $listing->fields['also_found_in_8'] . ' ' . $listing->fields['also_found_in_9'] . ' ' . $listing->fields['also_found_in_10'] . ' ' . $listing->fields['also_found_in_11'] . ' ' . $listing->fields['also_found_in_12'] . ' ' . $listing->fields['also_found_in_13'] . ' ' . $listing->fields['also_found_in_14'] . ' ' . $listing->fields['also_found_in_15'] . ' ' . $listing->fields['also_found_in_16'] . ' ' . $listing->fields['also_found_in_17'] . ' ' . $listing->fields['also_found_in_18'] . ' ' . $listing->fields['also_found_in_19'] . ' ' . $listing->fields['also_found_in_20'] . ' ' . $listing->fields['also_found_in_21'] . ' </h3>[B]';[/B]

[B]}[/B]

[B]$lc_text .= '[/B]<div class="listingDescription">' . zen_trunc_string(zen_clean_html(stripslashes(zen_get_products_description($listing->fields['products_id'], $_SESSION['languages_id']))), PRODUCT_LIST_DESCRIPTION) . '</div>';
}
break;

> 
> 
> Elsewhere on the website I have used this code
> 
> ```
<?php if (empty($also_found_in_1)) { echo ''; } else { echo 'Please note that this part has also been fitted to these alternative TV models:<div id="also_found">'; } ?>

How could I modify that so it works on the search results page.

try above code in red, the products listing page and the search result page should pick up the if statement.

7 Oct 2013, 11:49 AM
#13
digitalshadow avatar

digitalshadow

Totally Zenned

Join Date:
Mar 2009
Posts:
616
Plugin Contributions:
0

Re: Adding custom data to search results

rbarbour:

try above code in red, the products listing page and the search result page should pick up the if statement.

You are a genius, search result page now looks perfect.