Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2008
    Posts
    150
    Plugin Contributions
    0

    Default Linking the music product Artist extra internally

    In the "Record Artists" extra for music products, there is an "Artists Web Site" link available when filling in the "New Recording Artist" form.
    I would like to utilize this to link to my shop internally (either to a category or to a keyword search). However, when I enter a link to my own site, it opens a new tab and redirects to the site's main page instead of the category or text search I placed in the form. How can I prevent this rediredt and take the customer to a page in the same tab that shows the desired results? Thank you.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,350
    Blog Entries
    7
    Plugin Contributions
    271

    Default Re: Linking the music product Artist extra internally

    This might work:
    Near the end of tpl_product_music_info_display.php is this section of code:
    Code:
    <!--bof Product URL -->
    <?php
      if (zen_not_null($products_record_company_url)) {
        if ($flag_show_product_music_info_record_company == 1) {
    ?>
        <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>
    <?php
        } // $flag_show_product_info_record_company
      }
    ?>
    <!--eof Product URL -->

    replace with:

    Code:
    <!--bof Product URL -->
    <?php
      if (zen_not_null($products_record_company_url)) {
        if ($flag_show_product_music_info_record_company == 1) {
          $linked_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);
          if (strpos($products_record_company_url, HTTPS_SERVER) !== false) {
              $linked_url = $products_record_company_url;
          }
    ?>
        <p id="productInfoLink" class="productMusic centeredContent"><?php echo sprintf(TEXT_RECORD_COMPANY_URL, $linked_url); ?></p>
    <?php
        } // $flag_show_product_info_record_company
      }
    ?>
    <!--eof Product URL -->
    And then put the complete URL in as the record-company-url in the database (including https:// ). If that URL begins with the same URL that you use in your HTTPS_SERVER setting in /includes/configure.php then it will just output the URL directly, instead of doing a redirect.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Apr 2008
    Posts
    150
    Plugin Contributions
    0

    Default Re: Linking the music product Artist extra internally

    Quote Originally Posted by DrByte View Post
    This might work:
    Near the end of tpl_product_music_info_display.php is this section of code:
    Code:
    <!--bof Product URL -->
    <?php
      if (zen_not_null($products_record_company_url)) {
        if ($flag_show_product_music_info_record_company == 1) {
    ?>
        <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>
    <?php
        } // $flag_show_product_info_record_company
      }
    ?>
    <!--eof Product URL -->

    replace with:

    Code:
    <!--bof Product URL -->
    <?php
      if (zen_not_null($products_record_company_url)) {
        if ($flag_show_product_music_info_record_company == 1) {
          $linked_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);
          if (strpos($products_record_company_url, HTTPS_SERVER) !== false) {
              $linked_url = $products_record_company_url;
          }
    ?>
        <p id="productInfoLink" class="productMusic centeredContent"><?php echo sprintf(TEXT_RECORD_COMPANY_URL, $linked_url); ?></p>
    <?php
        } // $flag_show_product_info_record_company
      }
    ?>
    <!--eof Product URL -->
    And then put the complete URL in as the record-company-url in the database (including https:// ). If that URL begins with the same URL that you use in your HTTPS_SERVER setting in /includes/configure.php then it will just output the URL directly, instead of doing a redirect.
    Thank you. That worked great for the Record Companies extra. However, I need to apply it to music artists. I've tried to adapt your suggestion for the artist link, but regardless of what URL I place in the "Artists Web Site" field, the link always shows as a redirect, such as:
    /index.php?main_page=redirect&action=music_artist&artists_id=

  4. #4
    Join Date
    Jan 2004
    Posts
    66,350
    Blog Entries
    7
    Plugin Contributions
    271

    Default Re: Linking the music product Artist extra internally

    In which file? (There's no artist link in that file.)
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Apr 2008
    Posts
    150
    Plugin Contributions
    0

    Default Re: Linking the music product Artist extra internally

    Quote Originally Posted by DrByte View Post
    In which file? (There's no artist link in that file.)
    Correct. But that's the file you referenced above. So that's where I tried to put it, below the code for record company. Previously, I had only tried to get an artist link from the "New Recording Artist" form in the admin's extras.
    Regardless of what I enter there, the resulting link always returns me to the home page.

  6. #6
    Join Date
    Apr 2008
    Posts
    150
    Plugin Contributions
    0

    Default Re: Linking the music product Artist extra internally

    I replaced record_company with artist (or artists where applicable) and placed the following into tpl_product_music_info_display.php
    Code:
    <!--bof Artist URL -->
    <?php
      if (zen_not_null($products_artist_url)) {
        if ($flag_show_product_music_info_artist == 1) {
          $linked_url = zen_href_link(FILENAME_REDIRECT, 'action=music_artist&artists_id=' . zen_output_string_protected($music_extras->fields['artists_id']), 'NONSSL', true, false);
          if (strpos($products_artists_url, HTTPS_SERVER) !== false) {
              $linked_url = $products_artist_url;
          }
    ?>
        <p id="productInfoLink" class="productMusic centeredContent"><?php echo sprintf(TEXT_ARTIST_URL, $linked_url); ?></p>
    <?php
        } // $flag_show_product_info_artist
      }
    ?>
    <!--eof Artist URL -->
    Instead of replicating the behavior of the Record Company field, I get something like this:
    Name:  zen-cart-artist-link.png
Views: 44
Size:  17.6 KB
    The Record Company link goes to the correct page as entered in the admin>extras>Record Companies>Edit Record Company form. However, neither link produced for Artist goes to the URL entered in the admin>extras>Record Artists>Edit Recording Artist form. It appears to contain the correct artists_id, but always redirects to the home page.
    How can I get the Artist link to behave in the same manner as the Record Company link?

  7. #7
    Join Date
    Jan 2004
    Posts
    66,350
    Blog Entries
    7
    Plugin Contributions
    271

    Default Re: Linking the music product Artist extra internally

    /includes/modules/pages/product_music/main_template_vars_product_type.php
    Change
    Code:
    /*
     * extract info from queries for use as template-variables:
     */
      $products_artist_name = !empty($artist->fields['artists_name']) ? $artist->fields['artists_name'] : '';
      $products_artist_url = !empty($artist_info->fields['artists_url']) ? $artist_info->fields['artists_url'] : '';
      $products_record_company_name = !empty($record_company->fields['record_company_name']) ? $record_company->fields['record_company_name'] : '';
      $products_record_company_url = !empty($record_company_info->fields['record_company_url']) ? $record_company_info->fields['record_company_url'] : '';
      $products_music_genre_name = !empty($music_genre->fields['music_genre_name']) ? $music_genre->fields['music_genre_name'] : '';
      if (!empty($products_artist_url)) $products_artist_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=music_artist&artists_id=' . zen_output_string_protected($music_extras->fields['artists_id']), 'NONSSL', true, false) . '" rel="noopener noreferrer" 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) . '" rel="noopener noreferrer" target="_blank">'.$products_record_company_name.'</a>';
    to
    Code:
    /*
     * extract info from queries for use as template-variables:
     */
      $products_artist_name = !empty($artist->fields['artists_name']) ? $artist->fields['artists_name'] : '';
      $products_artist_url = !empty($artist_info->fields['artists_url']) ? $artist_info->fields['artists_url'] : '';
      $products_record_company_name = !empty($record_company->fields['record_company_name']) ? $record_company->fields['record_company_name'] : '';
      $products_record_company_url = !empty($record_company_info->fields['record_company_url']) ? $record_company_info->fields['record_company_url'] : '';
      $products_music_genre_name = !empty($music_genre->fields['music_genre_name']) ? $music_genre->fields['music_genre_name'] : '';
    //  if (!empty($products_artist_url)) $products_artist_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=music_artist&artists_id=' . zen_output_string_protected($music_extras->fields['artists_id']), 'NONSSL', true, false) . '" rel="noopener noreferrer" target="_blank">'.$products_artist_name.'</a>';
      if (!empty($products_artist_url)) {
        if (strpos($products_artist_url, HTTPS_SERVER) !== false) {
            $products_artist_name = '<a href="' . $products_artist_url . '">'.$products_artist_name.'</a>';
        } else {
            $products_artist_name = '<a href="' . zen_href_link(FILENAME_REDIRECT, 'action=music_artist&artists_id=' . zen_output_string_protected($music_extras->fields['artists_id']), 'NONSSL', true, false) . '" rel="noopener noreferrer" 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) . '" rel="noopener noreferrer" target="_blank">'.$products_record_company_name.'</a>';
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  8. #8
    Join Date
    Apr 2008
    Posts
    150
    Plugin Contributions
    0

    Default Re: Linking the music product Artist extra internally

    Thank you, that worked. I removed my attempt from tpl_product_music_info_display.php and made the change to main_template_vars_product_type.php as recommended.

    Curious as to why the changes for record_company were made in tpl_product_music_info_display.php, but altering artist is done in main_template_vars_product_type.php?
    If I want to make similar changes to the genre or format field, would I make those in main_template_vars_product_type.php as well?

 

 

Similar Threads

  1. v155 Applying Numinix Extra Fields to Product - Music
    By Joseph M in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 11 Aug 2018, 01:53 AM
  2. Displaying the correct page after inserting a "Music Genre" extra
    By kamion in forum Customization from the Admin
    Replies: 3
    Last Post: 7 Dec 2011, 02:52 AM
  3. Music Artist
    By cs_jono in forum General Questions
    Replies: 2
    Last Post: 24 Nov 2007, 08:21 PM
  4. linking artist to music
    By davidinho in forum Setting Up Categories, Products, Attributes
    Replies: 1
    Last Post: 19 Jun 2006, 04:19 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