Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Template Authors Note: Changes to product's URL handling!

    Zen Cart v1.5.3 changed the handling of the redirect page, used in the product information pages to display the product's URL, if supplied. This change is not downwardly compatible, so without template-specific changes for Zen Cart v1.5.3, any product URLs will no longer be displayed.

    I added the following conditional code in the tpl_product_info_display.php for the Product Notifications on product_info Page plugin, but on afterthought, there's a better solution out there that will bridge the gap for all information pages' display. I'll post that up here when I've got it completed.
    Code:
    <!--bof Product URL -->
    <?php
      if (zen_not_null($products_url)) {
        if ($flag_show_product_info_url == 1) {
    //-bof-product_info_notifications-lat9 *** 2 of 2 ***
    // -----
    // Note:  Zen Cart v1.5.3 removes action=url and replaces it with action=product -- check version.
    // -----
          if (PROJECT_VERSION_MAJOR > '1' || PROJECT_VERSION_MINOR >= '5.3') {
    ?>
        <p id="productInfoLink" class="productGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=product&products_id=' . zen_output_string_protected($_GET['products_id']), 'NONSSL', true, false)); ?></p>
    <?php
          } else {
    ?>
        <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
          }
    //-eof-product_info_notifications-lat9 *** 2 of 2 ***
        } // $flag_show_product_info_url
      }
    ?>
    <!--eof Product URL -->

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Template Authors Note: Changes to product's URL handling!

    After thinking about this overnight, I believe that the right way for this to be handled is for template authors to bite the bullet and make the changes necessary for their templates to fully operate in a Zen Cart v1.5.3 (and later) environment -- while maintaining compatibility with previous Zen Cart versions. The change made by the Zen Cart developers (removing the redirect to any URL, containing those redirects to "known", database-specified locations) serves to further "harden" the Zen Cart's base and I advocate working with the change rather than trying to circumvent it.

    My recommendation, FWIW, is for template authors to update their template offerings for full v1.5.3 support, delivering the Zen Cart v1.5.3 version of /includes/modules/pages/redirect/header_php.php (which contains the updated redirect variable processing) as part of the template's distribution zip-file (to provide compatibility with older Zen Cart versions) and then making the following changes to the various product types' information-display pages.

    /includes/modules/pages/product_music_info/main_template_vars_product_type.php, change lines 68 and 69 from:
    Code:
    if (!empty($products_artist_url)) $products_artist_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_artist_url), 'NONSSL', true, false) . '" target="_BLANK">'.$products_artist_name.'</a>';
    
    if (!empty($products_record_company_url)) $products_record_company_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_record_company_url), 'NONSSL', true, false) . '" target="_BLANK">'.$products_record_company_name.'</a>';
    to
    Code:
    if (!empty($products_artist_url)) $products_artist_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=music_arist&artists_id=' . zen_output_string_protected($music_extras->fields['artists_id']), 'NONSSL', true, false) . '" target="_BLANK">'.$products_artist_name.'</a>';
    
    if (!empty($products_record_company_url)) $products_record_company_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=music_record_company&record_company_id=' . zen_output_string_protected($music_extras->fields['record_company_id']), 'NONSSL', true, false) . '" target="_BLANK">'.$products_record_company_name.'</a>';
    /includes/templates/template_default/templates/tpl_document_general_info_display.php, change line 214 from:
    Code:
     <p id="productInfoLink" class="docGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_url), 'NONSSL', true, false)); ?></p>
    to
    Code:
     <p id="productInfoLink" class="docGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=product&products_id=' . zen_output_string_protected($_GET['products_id']), 'NONSSL', true, false)); ?></p>
    /includes/templates/template_default/templates/tpl_document_product_info_display.php, change line 215 from:
    Code:
     <p id="productInfoLink" class="docProduct centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_url), 'NONSSL', true, false)); ?></p>
    to
    Code:
     <p id="productInfoLink" class="docProduct centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=product&products_id=' . zen_output_string_protected($_GET['products_id']), 'NONSSL', true, false)); ?></p>
    /includes/templates/template_default/templates/tpl_product_free_shipping_info_display.php, change line 215 from:
    Code:
     <p id="productInfoLink" class="freeShip centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_url), 'NONSSL', true, false)); ?></p>
    to
    Code:
     <p id="productInfoLink" class="freeShip centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=product&products_id=' . zen_output_string_protected($_GET['products_id']), 'NONSSL', true, false)); ?></p>
    /includes/templates/template_default/templates/tpl_product_info_display.php, change line 216 from:
    Code:
     <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>
    to
    Code:
     <p id="productInfoLink" class="productGeneral centeredContent"><?php echo sprintf(TEXT_MORE_INFORMATION, zen_href_link(FILENAME_REDIRECT, 'action=product&products_id=' . zen_output_string_protected($_GET['products_id']), 'NONSSL', true, false)); ?></p>
    /includes/templates/template_default/templates/tpl_product_music_info_display.php, change line 227 from
    Code:
    <p id="productInfoLink" class="productMusic centeredContent"><?php echo sprintf(TEXT_RECORD_COMPANY_URL, zen_href_link(FILENAME_REDIRECT, 'action=url&goto=' . urlencode($products_record_company_url), 'NONSSL', true, false)); ?></p>
    to
    Code:
    <p id="productInfoLink" class="productMusic centeredContent"><?php echo sprintf(TEXT_RECORD_COMPANY_URL, zen_href_link(FILENAME_REDIRECT, 'action=music_record_company&record_company_id=' . zen_output_string_protected($music_extras->fields['record_company_id']), 'NONSSL', true, false)); ?></p>

  3. #3
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Template Authors Note: Changes to product's URL handling!

    Maybe only partially on topic with this thread, or possibly spot on, but seeing the recommended changes for various product types to support backwards/forwards compatibility of templates, I was wondering if there were plans to update the FAQ on product types found at: http://www.zen-cart.com/content.php?...ogrammer-view) even if it is/was to update the thread referenced at the bottom of the article. This looks like a wonderful solution as most do and glad that considered incorporating forward/backwards compatibility into the solution (as long as it is still possible).
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Template Authors Note: Changes to product's URL handling!

    FWIW, since I'm not seeing anyone jumping on this, there's a better more compatible solution that will work for both full template plugins and for plugins that are simply template modifications. I'll post this up once I've got it coded (with a zip-file this time!).

  5. #5
    Join Date
    Jul 2012
    Posts
    16,718
    Plugin Contributions
    17

    Default Re: Template Authors Note: Changes to product's URL handling!

    Quote Originally Posted by lat9 View Post
    FWIW, since I'm not seeing anyone jumping on this, there's a better more compatible solution that will work for both full template plugins and for plugins that are simply template modifications. I'll post this up once I've got it coded (with a zip-file this time!).
    With all due respect, I'm not sure what action you were hoping to see to identify that the above was being jumped on, but I certainly have flagged this thread to implement when my site is upgraded to 1.5.3, as well am coworking on a project that adds a product type and associated product type info displaay page and was going to incorporate the above into it to maintain compatibility with old and new ZC versions.

    I have seen one template author in at least one thread get asked if their template was compatible with 1.5.3, and the answer was yes... So not sure if word has gotten out to the template authors that perhaps there is a little something more that needs to be done to ensure full functionality is maintained in this new world. :)

    I'll do what I can to lead to this thread, but would think/hope there would be some way to get the word out a little "easier".
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #6
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Template Authors Note: Changes to product's URL handling!

    That was just my way of requesting that anyone that is quietly implementing the previous solution hold on while I develop one that's more robust! The previous solution (distributing the Zen Cart v1.5.3 version of the redirect page's header_php.php) works for full template-author distribution but doesn't help much for plugins that only modify one of the product-type-display pages.

    My updated solution (see attached zip-file) uses a common class ($product_redirect) that performs the Zen Cart version-specific mapping to the redirect page's interface. The class is instantiated during the Zen Cart's startup and provides three mapping functions:
    1. $product_redirect->products_url_link ($products_id). Used to display the products_url field for the selected product.
    2. $product_redirect->music_record_company_link ($products_id). Used to display the music product's record_company_url.
    3. $product_redirect->music_artist_link ($products_id). Used to display the music product's artists_url

    In each case, the function returns an href_link to the specified URL (as pulled from the database).

    The changes to the template files (and the product_music_info template variables file) can be made one time and distributed (with the class and its auto_loader) to operate under all Zen Cart versions. For example, the change to /includes/modules/pages/product_music_info/main_template_vars_product_type.php looks like:
    Code:
    //-bof-compatible_redirects-lat9  *** 1 of 1 ***
    //  if (!empty($products_artist_url)) $products_artist_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=music_arist&artists_id=' . zen_output_string_protected($music_extras->fields['artists_id']), 'NONSSL', true, false) . '" target="_BLANK">'.$products_artist_name.'</a>';
      if (!empty($products_artist_url)) $products_artist_name = '<a href="' . $product_redirect->music_artist_link ($_GET['products_id']) . '" target="_BLANK">'.$products_artist_name.'</a>';
      
    //  if (!empty($products_record_company_url)) $products_record_company_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=music_record_company&record_company_id=' . zen_output_string_protected($music_extras->fields['record_company_id']), 'NONSSL', true, false) . '" target="_BLANK">'.$products_record_company_name.'</a>';
    
      if (!empty($products_record_company_url)) $products_record_company_name = '<a href="' . $product_redirect->music_record_company_link ($_GET['products_id']) . '" target="_BLANK">'.$products_record_company_name.'</a>';
    //-eof-compatible_redirects-lat9  *** 1 of 1 ***
    The key is to get template authors and authors of plugins that modify the product template files to all distribute the class and auto_loader with their updates.

    compatible_redirects_v100.zip

  7. #7
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    976
    Plugin Contributions
    6

    Default Re: Template Authors Note: Changes to product's URL handling!

    Hi lat9

    Thanks for the headsup, although I do not quite comprehend the code, especially that in redirect/header_php.php.

    Your code does not mention any manufacturer links - core or mods (eg antiquated manufacturers_about mod which utilises the core manufacturer_info sidebox). Have you looked into any of these? If so, are any OK?

    The only other mod I have installed that has links is event calendar, which has two link options on the event description page - one to an in-store product and the other to an event information page that may be external. This mod has been upgraded for zc151 but will require several other modifications to bring it up to 153 standard. It is not clear to me whether all link types will need to be addressed for the 153 upgrade.

    Thanks
    Last edited by dw08gm; 5 Nov 2014 at 10:31 AM.

  8. #8
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Template Authors Note: Changes to product's URL handling!

    The manufacturers' links -- and associated redirect interface -- were already handled in a "sanitized" manner, so required no change.

    It's not all links that are affected, only those product-specific links (like to a product's defined website) that require the use of the redirect page (main_page=redirect) for their display are affected.

  9. #9
    Join Date
    Sep 2008
    Location
    DownUnder, overlooking South Pole.
    Posts
    976
    Plugin Contributions
    6

    Default Re: Template Authors Note: Changes to product's URL handling!

    Could you please say some more about what is being "sanitised" by the code.

    Is it something to do with $_GET() passing certain information through the links?

  10. #10
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,399
    Plugin Contributions
    87

    Default Re: Template Authors Note: Changes to product's URL handling!

    Quote Originally Posted by dw08gm View Post
    Could you please say some more about what is being "sanitised" by the code.

    Is it something to do with $_GET() passing certain information through the links?
    The previous versions of the redirect page's processing "blindly" transferred control to the product URL passed via $_GET; updated processing for redirection to a product's URL takes the product's ID as input (via $_GET) and looks the URL up from the product's definition in the database.

 

 

Similar Threads

  1. 1.5.0 modders doing SQL changes please note!
    By swguy in forum Upgrading to 1.5.x
    Replies: 1
    Last Post: 12 Jun 2012, 11:18 PM
  2. v139h Mod Authors Please Note: Smart idea if you're adding configuration entries to addons
    By swguy in forum Contribution-Writing Guidelines
    Replies: 5
    Last Post: 6 Feb 2012, 10:44 PM
  3. Problems with URL Changes
    By Transmutator in forum Installing on a Linux/Unix Server
    Replies: 1
    Last Post: 18 Feb 2009, 12:46 AM
  4. Add custom note to product?
    By z3n in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 21 May 2008, 06:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR