solved Listing songs and artists per genre

maxcinsay
@maxcinsay
11 years ago
60 posts
When I request the songs or artists in a genre, how can I do pagination? I have below the commands to request the list of results and they work fine, but when I try to use pagination it will return results from outside the genre defined.

How can I pass the variable of the genre to make the pagination possible?

Songs:
{jrCore_list module="jrAudio" chart_field="audio_file_stream_count" chart_days="7" search = "audio_genre = {$genre_to_show|replace:'songs_':''}" order_by="audio_file_stream_count numerical_desc" quota_id="4" template="new_songs_details.tpl" pagebreak="10" page=$_post.p assign="TOP_TEN_CHARTS"}

Artists:
{jrCore_list module="jrProfile" order_by="profile_name asc" search1="profile_active = 1"
search2="profile_genre = {$genre_to_show|replace:'songs_':''}"
template="artist_list_details.tpl" require_image="profile_image" assign="ALL_ARTIST"
pagebreak="10" page=$_post.p}

Thanks for the help!

updated by @maxcinsay: 02/03/14 09:28:42PM
brian
@brian
11 years ago
10,148 posts
The "pagebreak" param has nothing to do with what the search is, so I would just double check that your search is correct - i.e. there should be no spaces and the smarty needs to be correct - i.e. this:

search = "audio_genre = {$genre_to_show|replace:'songs_':''}"

is not correct - you are going to need to "prepare" $genre_to_show before hand - I haven't tried this but you'll need to do something like:

{assign var="search_genre" value=$genre_to_show|replace:'songs_':''}
....
{jrCore_list ... search="audio_genre = `$search_genre`" ... }

Since JR5 already stores genres, can you not just use "audio_genre" instead of trying to manipulate the "genre_to_show" variable?


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

updated by @brian: 12/26/13 03:00:42PM
maxcinsay
@maxcinsay
11 years ago
60 posts
Thanks, what you are saying works. That what I have been doing.

My situation arises when I want to display more results, lets say I show 10 songs in the 'Country' category and then I want to show 10 more and so on until the end of the songs. When doing the pagination I dont have the variable of the genre passed to {jrCore....} and therefore it just sends more results without taking the genre in consideration.

Here is the example:
This is the page where you can pick a genre:
http://dev5.r2rlive.com/artists/

And here is the page showing the results for that genre, the genre is passed in the url and them prepared as you mentioned before:
http://dev5.r2rlive.com/artists/songs_Country

I want to be able to show all the music and artists in the genre with pagination.

In the home page you can see what Im trying to accomplish when clicking more songs:
http://dev5.r2rlive.com/
brian
@brian
11 years ago
10,148 posts
You need to add:

pager=true

To your jrCore_list call so you use the internal pager - it will create the correct URL for prev/next pages.

Hope this helps!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net
maxcinsay
@maxcinsay
11 years ago
60 posts
I was able to get it working but for that I had to do my own jrLoad functions that inserts results with ajax. Im passing the variable of the genre to the function and then create the {jrCore_list call.

I could not use the pager since it will break the persistent player on the website.

This is a example:
var moreSongsTest = function(urlz,nextPage,totalPages,genreSelected) {
console.log(genreSelected);
var response;
$.ajax({ type: "GET",
url: urlz+nextPage+'&genre='+genreSelected,
async: false,
cache:false,
datatype:"html",
success : function(data)
{

response= $(data).find('li.song_container');
console.log(response);
nextPage = parseInt(nextPage) + 1;
if(nextPage == totalPages+1) {
$('.replace_linkGenre').html(' You reached the end of the list, No more songs');
} else {
$('.replace_linkGenre').html('More songs');
}



}
});
$('#new_songsTest').append(response);
}
brian
@brian
11 years ago
10,148 posts
maxcinsay:
I could not use the pager since it will break the persistent player on the website.

Yes - you would have to do something custom if this is the case.

Thanks!


--
Brian Johnson
Founder and Lead Developer - Jamroom
https://www.jamroom.net

Tags