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.
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.
Re: Linking the music product Artist extra internally
Quote:
Originally Posted by
DrByte
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=
Re: Linking the music product Artist extra internally
In which file? (There's no artist link in that file.)
Re: Linking the music product Artist extra internally
Quote:
Originally Posted by
DrByte
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.
1 Attachment(s)
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:
Attachment 19594
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?
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>';
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?