Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Can I add products_url into product_listing.php?

Can I add products_url into product_listing.php?

Views: 1,141

Results 1 to 9 of 9
21 Mar 2013, 9:19 PM
#1
littlepunk29 avatar

littlepunk29

New Zenner

Join Date:
Nov 2007
Posts:
16
Plugin Contributions:
0

Can I add products_url into product_listing.php?

I would like to display the product URL field in the product_listing.php page. This way it would show up in the product description.

The reason I would like to do this is because I am using this to link to the MSDS for the product, and the store is just a showcase, not for purchasing, so there isn't a need to go all the way into the product info page if you didn't need to.

Normally the text says "For more information, please view this product's website."

I have changed it to say "For more information, please view this product's MSDS."

I just need it to show up in the other page. I have tried using the code from the tpl_product_info.php page with very slight modifications to the quotes to get it to function without breaking the description, and I have gotten the description to draw out, but without the URL even though the code is there. I believe that the issue is that I never get the URL field from the database into this file, but I am at a loss of how to do that.

I started with the else statement because that is the type of description that shows up on my store. Basically I added the <!--bof Product URL--> to the <!--eof Product URL-->

Here is the code that I have added @ line 150:

else {
$lc_text = '<h3 class="itemTitle"><a href="' . zen_href_link(zen_get_info_page($listing->fields['products_id']), 'cPath=' . (($_GET['manufacturers_id'] > 0 and $_GET['filter_id']) > 0 ? zen_get_generated_category_path_rev($_GET['filter_id']) : ($_GET['cPath'] > 0 ? zen_get_generated_category_path_rev($_GET['cPath']) : zen_get_generated_category_path_rev($listing->fields['master_categories_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) . '

<!--bof Product URL -->
<?php
  if (zen_not_null($products_url)) {
    if ($flag_show_product_info_url == 1) {
?>

<p id="productInfoLink" class="productGeneral centeredContent">

<?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, "action=url&goto=" . urlencode($products_url), "NONSSL", true, false)); ?>

</p>

<?php
    } // $flag_show_product_info_url
  }
?>
<!--eof Product URL -->
</div>';
21 Mar 2013, 9:52 PM
#2
littlepunk29 avatar

littlepunk29

New Zenner

Join Date:
Nov 2007
Posts:
16
Plugin Contributions:
0

Re: Can I add products_url into product_listing.php?

Please excuse me for not mentioning that this is NOT the original product_listing.php file, but the one for the column_layout_grid_2_3_1

21 Mar 2013, 10:59 PM
#3
kobra avatar

kobra

Black Belt

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

Re: Can I add products_url into product_listing.php?

Why not try and place the url as the first thing in the description

22 Mar 2013, 3:05 PM
#4
littlepunk29 avatar

littlepunk29

New Zenner

Join Date:
Nov 2007
Posts:
16
Plugin Contributions:
0

Re: Can I add products_url into product_listing.php?

I am not the one managing the store. I want to keep it consistent, so I would like to use the already provided easy button for them to click so I can have a consistent style to everything. I am already having to add the code into the description for the Tech Sheet because some products have an MSDS and a tech sheet, but most all products will require the MSDS. Trying to go the simplest route for the client.

22 Mar 2013, 7:46 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: Can I add products_url into product_listing.php?

littlepunk29:

Please excuse me for not mentioning that this is NOT the original product_listing.php file, but the one for the column_layout_grid_2_3_1

Please also post your ZC version number.

You'll need to add the products_url field to the SELECT statement in your /includes/index_filters/default_filter.php file if you want it to be available in the $listing_sql query and the $listing->fields array as $listing->fields['products_url']

22 Mar 2013, 10:18 PM
#6
littlepunk29 avatar

littlepunk29

New Zenner

Join Date:
Nov 2007
Posts:
16
Plugin Contributions:
0

Re: Can I add products_url into product_listing.php?

So sorry, v1.5.0

In my default_filter.php file,

I found a ton of "$listing_sql"

not sure which one to put it in.

I searched but cannot find "$listing->fields"

22 Mar 2013, 10:40 PM
#7
rbarbour avatar

rbarbour

Totally Zenned

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

Re: Can I add products_url into product_listing.php?

23 Mar 2013, 1:10 AM
#8
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: Can I add products_url into product_listing.php?

Great concentrated info there!

You also need to change the way you are writing your code. You are trying to output the link immediately instead of putting it into $lc_text for later output.```php
PRODUCT_LIST_DESCRIPTION) . '

<!--bof Product URL --> <?php if (zen_not_null($products_url)) { if ($flag_show_product_info_url == 1) { ?> <p id="productInfoLink" class="productGeneral centeredContent"> <?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, "action=url&goto=" . urlencode($products_url), "NONSSL", true, false)); ?> </p> <?php } // $flag_show_product_info_url } ?> <!--eof Product URL --> </div>'; ``` needs to become something like```php PRODUCT_LIST_DESCRIPTION) . $product_url_link . ' </div>'; ``` and before the $lc_text = line, add this ```php $product_url_link = ''; if (zen_not_null($products_url)) { if ($flag_show_product_info_url == 1) { $product_url_link = ' <!--bof Product URL --> <p class="productInfoLink productGeneral centeredContent"> ' . sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, "action=url&goto=" . urlencode($products_url), "NONSSL", true, false)) . ' </p> <!--eof Product URL --> '; } // $flag_show_product_info_url } ``` I don't know if $flag_show_product_info_url is set in the product listing page, or only in the product info page. If this doesn't work, that would be something to look at.
26 Mar 2013, 7:24 PM
#9
littlepunk29 avatar

littlepunk29

New Zenner

Join Date:
Nov 2007
Posts:
16
Plugin Contributions:
0

Re: Can I add products_url into product_listing.php?

I have edited my 2 files to no avail. I have read the other forum topic, and tried to get the
pd.products_url
in my default_filter.php file.
I have added it in 4 places like it said. Line 31, 46, 61, and 76. Please let me know if this is correct.
Attachment #12240

Here is my product_listing.php
I have edited at line 152 and the end of 167.
Attachment #12241

Nothing changes, but at the same time, it doesn't break anything either.

Thanks for the help!