Results 1 to 10 of 13

Hybrid View

  1. #1
    Join Date
    Apr 2014
    Location
    Los Angeles
    Posts
    41
    Plugin Contributions
    0

    help question PHP - Lost, any advice?

    Hello,

    I was wondering why adding the code in red below to 'modules/custom/product_listing.php' doesn't display the media link after the price in the Product Listings. Is there anywhere else I should try to add this code, or is this a much bigger job than I think?

    Code:
            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']), '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) . '</div>' ;
            } 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) . '</div>' ;
            }
    		require($template->get_template_dir('/tpl_modules_media_manager.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_media_manager.php') ;
            break;

  2. #2
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: PHP Zen-Lost, any advice?

    You need to accumulate the output into $lc_text, not just process/output it immediately. Is it outputting somewhere early in the page before any of the listing? That is what I would expect if it is functioning at all now.

  3. #3
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: PHP Zen-Lost, any advice?

    That is a reasonable place to add the code; you just need to alter it so that it saves the output in a variable which can then be appended to $lc_text.
    PHP Code:
    //fetch the link content for the current product and save in $your_link_content
    $lc_text .= $your_link_content

  4. #4
    Join Date
    Apr 2014
    Location
    Los Angeles
    Posts
    41
    Plugin Contributions
    0

    Default Re: PHP Zen-Lost, any advice?

    Something like this?

    Code:
            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']), '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) . '</div>' ;
            } 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) . '<span class="Play" href="' zen_href_link(DIR_WS_MEDIA  . $za_clip['clip_filename'], '', 'NONSSL', false, true, true) .  '" target="_blank">' . '<span class="mediaClipFilename">' . $za_clip['clip_filename'] . '</span>' . (!empty($za_clip['clip_type']) ? '<span class="mediaClipType"> (' . $za_clip['clip_type'] . ')</span>' : ''); '</div>' ;
            }
            break;

  5. #5
    Join Date
    Apr 2014
    Location
    Los Angeles
    Posts
    41
    Plugin Contributions
    0

    help question Re: PHP Zen-Lost, any advice?

    Still going crazy Any suggestions?


    Added to top of 'product_listing.php'

    Code:
    		function getScriptOutput($path, $print = FALSE){
    			ob_start();
    			if( is_readable($path) && $path )
    			{
    				include $path;
    			}
    			else
    			{
    				return FALSE;
    			}
    			if( $print == FALSE )
    				return ob_get_clean();
    			else
    				echo ob_get_clean();
    		}

    And made these changes, but no luck..
    Code:
            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']), '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) . '</div>' ;
            } else {
    
    		$path = DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_media_manager.php');
    		$html = getScriptOutput($path);
    		$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) . $html . '</div>' ;
            }
            break;
    Please help!

  6. #6
    Join Date
    Apr 2014
    Location
    Los Angeles
    Posts
    41
    Plugin Contributions
    0

    Default Re: PHP Zen-Lost, any advice?

    This doesn't work either lol?

    Code:
            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']), '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) . '</div>' ;
            } else {
    		
      require(DIR_WS_MODULES . zen_get_module_directory('media_manager.php'));
    				$za_play = $zq_clips->fields['clip_filename'] ;
    				$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) . '<a href ="' . $za_play . '">' . '<img src="images/play_button.png"/>' . '</div>' ;
            }
            break;

  7. #7
    Join Date
    Apr 2014
    Location
    Los Angeles
    Posts
    41
    Plugin Contributions
    0

    Default Re: PHP Zen-Lost, any advice?

    I think I can get this working if I can just figure out how to set a variable ($za_play) to the 'clip filename' in 'media_manager.php' Any suggestions as to what I'm doing wrong?

    Code:
    <?php
    /**
     * iterates thru media collections/clips
     *
     * @package productTypes
     * @copyright Copyright 2003-2009 Zen Cart Development Team
     * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
     * @version $Id: media_manager.php 11825 2009-01-15 09:46:19Z drbyte $
     */
    if (!defined('IS_ADMIN_FLAG')) {
      die('Illegal Access');
    }
    
    /**
     * get list of media collections assigned to specified product
     */
    $zv_collection_query = "select media_id, product_id from " . TABLE_MEDIA_TO_PRODUCTS . "
                            where product_id = '" . (int)$_GET['products_id'] . "'";
    $zq_collections = $db->Execute($zv_collection_query);
    $zv_product_has_media = false;
    $za_play = 'HELLO';
    /**
     * loop thru collections to identify actual media clips
     */
    if ($zq_collections->RecordCount() > 0) {
      $zv_product_has_media = true;
      while (!$zq_collections->EOF) {
        /**
         * get names of assigned media collections
         */
        $zf_media_manager_query = "select media_id, media_name from " . TABLE_MEDIA_MANAGER . "
                                   where media_id = '" . (int)$zq_collections->fields['media_id'] . "'";
        $zq_media_manager = $db->Execute($zf_media_manager_query);
        if ($zq_media_manager->RecordCount() < 1) {
          $zv_product_has_media = false;
        } else {
          /**
           * build array of [collection_id][text] = collection-name
           */
          $za_media_manager[$zq_media_manager->fields['media_id']] = array('text' => $zq_media_manager->fields['media_name']);
          /**
           * get list of media clips associated with the current media collection, sorted by filename (to allow display sort order to be controlled by filename)
           */
          $zv_clips_query = "select media_id, clip_id, clip_filename, clip_type from " . TABLE_MEDIA_CLIPS . "
                             where media_id = '" . (int)$zq_media_manager->fields['media_id'] . "' order by clip_filename";
          $zq_clips = $db->Execute($zv_clips_query);
          if ($zq_clips->RecordCount() < 1) {
            $zv_product_has_media = false;
          } else {
            while (!$zq_clips->EOF) {
              /**
               * get list of media types and filenames associated with the current media
               * @TODO - run this as separate static array, since only needs to run once, not repeatedly in a loop
               */
              $zf_clip_type_query = "select type_ext, type_name from " . TABLE_MEDIA_TYPES . "
                                     where type_id = '" . (int)$zq_clips->fields['clip_type'] . "'";
    
              $zq_clip_type = $db->Execute($zf_clip_type_query);
    
              $za_media_manager[$zq_media_manager->fields['media_id']]['clips'][$zq_clips->fields['clip_id']] =
                    array('clip_filename' => $zq_clips->fields['clip_filename'],
                          'clip_type' => $zq_clip_type->fields['type_name']);
              $zq_clips->MoveNext();
    		  
            }
          }
        }
        $zq_collections->MoveNext();
      }
    }
    $zv_product_has_media = (sizeof($za_media_manager)) > 0 ? TRUE : FALSE;
    
    $za_play = $zq_clips->fields['clip_filename'];

  8. #8
    Join Date
    Apr 2014
    Location
    Los Angeles
    Posts
    41
    Plugin Contributions
    0

    Default Re: PHP Zen-Lost, any advice?

    Thanks for the reply! No, it's not outputting anything. When I append the code it's calling from 'tpl_modules_media_manager' to $lc_text it just returns a value of '1' with no links. Is there any way I can slip that code into the template file 'tpl_product_listing' or anywhere else to make it work?

 

 

Similar Threads

  1. v154 Any good advice on adding PHP Cron Jobs?
    By SpaceMonkey in forum General Questions
    Replies: 19
    Last Post: 4 Dec 2015, 12:30 AM

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