Zero108 Posted July 1, 2018 Share Posted July 1, 2018 Подскажите, пожалуйста, как сделать сортировку по названию композиций (song_title - название поля с названием композиции в базе данных) всегда, по умолчанию, вот на такой странице. Сейчас при каждом обновлении сортировка рандомная. Шаблон такой: {{$rowIds = array();}} {{foreach $rows as $row}} {{$idField = $row::$databaseColumnId;}} {{$rowIds[] = $row->$idField;}} {{endforeach}} {{if count( $rows )}} <table class="ipsTable"> <tbody> {{foreach $rows as $row}} {{$idField = $row::$databaseColumnId;}} {{if $row->mapped('moved_to')}} {{if $movedTo = $row->movedTo()}} <tr> <td> <i class="fa fa-arrow-left ipsType_large"></i> </td> <td> <h4 class='ipsDataItem_title ipsType_break'> <em><a href='{$movedTo->url()}' title='{lang="go_to_new_location"}'>{wordbreak="$row->mapped('title')"}</a></em> </h4> <div class='ipsDataItem_meta'> <p class='ipsType_reset ipsType_light ipsType_blendLinks'>{lang="moved_to" sprintf="$movedTo->container()->url(), $movedTo->container()->_title"}</p> </div> </td> <td> <div class='ipsPos_right' style='padding-right: 15px;'> {{if $table && $table->canModerate()}} <span class='ipsCustomInput'> <input type='checkbox' data-role='moderation' name="moderate[{$row->$idField}]" data-actions="{expression="implode( ' ', $table->multimodActions( $row ) )"}" data-state='{{if $row->tableStates()}}{$row->tableStates()}{{endif}}'> <span></span> </span> {{endif}} </div> </td> </tr> {{endif}} {{else}} <tr> <td style='padding-left: 0px !important;'> <div id='songRowInfo' class='ipsSpacer_bottom'> <a href="{$row->url()}" rel='loadAjaxPage' data-section='Songs' title='{$row->title}'> <div class="song-play-icon" style='margin-left: 10px; margin-right: 10px'></div> </a> <div class='ipsPos_left'> {{if $table}} {{if $row->mapped('locked')}} <i class="fa fa-lock"></i> {{endif}} {{if $row->mapped('pinned')}} <span data-ipsTooltip title='{lang="pinned"}'><i class='fa fa-thumb-tack'></i></span> {{endif}} {{if $row->hidden() === -1 || $row->hidden() === 1}} <span> {{if $row->hidden() === -1}} <span class="ipsBadge ipsBadge_icon ipsBadge_small ipsBadge_warning" data-ipsTooltip title='{$row->hiddenBlurb()}'><i class='fa fa-eye-slash'></i></span> {{elseif $row->hidden() === 1}} <span class="ipsBadge ipsBadge_icon ipsBadge_small ipsBadge_warning" data-ipsTooltip title='{lang="pending_approval"}'><i class='fa fa-warning'></i></span> {{endif}} </span> {{endif}} {{endif}} {{if $row->mapped('title')}} <a class='ipsType_normal' rel='loadAjaxPage' data-section='Songs' href='{$row->url()}' title='{$row->title} - {$row->singers()}'> {wordbreak="$row->mapped('title')"} </a> {{if \IPS\Application::appIsEnabled( 'nexus' ) and settings.mbconf_nexus_on}} <span class="songPrice"> {{if $price = $row->price()}}{$price|raw}{{else}}{lang="song_free"}{{endif}} </span> {{endif}} <br> <span class='ipsType_blendLinks ipsType_light'>{$row->artistLinks($row->singers())|raw}</span> {{else}} <em class="ipsType_light">{lang="content_deleted"}</em> {{endif}} </div> </div> </td> <td> <span class='ipsType_light ipsResponsive_hidePhone' data-ipstooltip title='{lang="musicbox_views"}'> <i class="fa fa-headphones"></i> {number="$row->views"} </span> <div class='ipsPos_right'> <span class='ipsResponsive_hidePhone'>{template="songActions" app="musicbox" group="global" params="$row"}</span> {{if $table && $table->canModerate()}} {{$idField = $row::$databaseColumnId;}} <span class='ipsCustomInput ipsPos_right'> <input type='checkbox' data-role='moderation' name="moderate[{$row->$idField}]" data-actions="{expression="implode( ' ', $table->multimodActions( $row ) )"}" data-state='{{if $row->tableStates()}}{$row->tableStates()}{{endif}}'> <span></span> </span> {{endif}} </div> {{if $row->container()->bitoptions['rating']}} <div class='ipsPos_right ipsResponsive_hideTablet ipsResponsive_hidePhone' style='margin-top:-3px !important; margin-right:30px !important;' data-ipsTooltip title='{lang="musicbox_top_avg_rating"}: {number="$row->rating_average"}'> {template="rating" group="global" location="front" app="core" params="'small', $row->rating_average"} </div> {{endif}} </td> </tr> {{endif}} {{endforeach}} </tbody> </table> {{endif}} Ссылка на приложение. Файл такой:artists.php Link to comment Share on other sites More sharing options...
newbie Posted July 1, 2018 Share Posted July 1, 2018 Файл такой: $select = \IPS\Db::i()->select( '*', 'musicbox_artists', $where, 'RAND()', array( ( $page - 1 ) * $perpage, $perpage ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS ); RAND() заменить на artist_nameНо, судя по файлу, это для https://www.a108.net/listen/performers/Подскажите, пожалуйста, как сделать сортировку по названию композиций (song_title - название поля с названием композиции в базе данных) всегда, по умолчанию, вот на такой странице. Не вижу там рандомной сортировки композиций. 1 Link to comment Share on other sites More sharing options...
Zero108 Posted July 1, 2018 Author Share Posted July 1, 2018 Спасибо, это тоже пригодилось. Исправил аналогично RAND() в файле profile.php на song_title. Link to comment Share on other sites More sharing options...
Zero108 Posted July 1, 2018 Author Share Posted July 1, 2018 Вот тут еще осталось по title отсортировать? Какую переменную заменить на song_title или что-то еще?Прицепленный файл точно тот (проверил - если его удаляешь, то страница не работает).view.php Link to comment Share on other sites More sharing options...
newbie Posted July 2, 2018 Share Posted July 2, 2018 Прицепленный файл точно тот (проверил - если его удаляешь, то страница не работает).Тут нет нужного. \applications\musicbox\sources\Song\Song.php'song_playlist_pos ASC' Link to comment Share on other sites More sharing options...
Zero108 Posted July 2, 2018 Author Share Posted July 2, 2018 Немного не понял. В этом файле в одном месте уже написано следующее: foreach( \IPS\Db::i()->select( '*', 'musicbox_songs', "find_in_set('{$this->id}',song_inPlaylist) <> 0", 'song_playlist_pos ASC') as $s ) Link to comment Share on other sites More sharing options...
Zero108 Posted July 2, 2018 Author Share Posted July 2, 2018 (edited) Вот сделал так: 'song_playlist_pos DESC' Теперь сортирует в обратном порядке и то не везде. В начале списка по-порядку идет, а потом в разнобой: 178 Aindra_Das_-_(2004_10.28)_Kirtan_After_Damodarastaka - Shripad Aindra das179 Aindra_Das_-_(2009_03.16)_Varsana_Kirtan_01 - Shripad Aindra das180 Aindra_Das_-_(2004_10.29)_Kirtan - Shripad Aindra das Edited July 2, 2018 by Zero108 Link to comment Share on other sites More sharing options...
newbie Posted July 2, 2018 Share Posted July 2, 2018 Немного не понял.Я написал, что нужно изменить. 'song_playlist_pos ASC'сортировка по позициям.Замените на 'song_title ASC' 1 Link to comment Share on other sites More sharing options...
Zero108 Posted July 10, 2018 Author Share Posted July 10, 2018 Еще одна страница, где хотелось бы отсортировать названия групп маркеров по названию. Link to comment Share on other sites More sharing options...
newbie Posted July 11, 2018 Share Posted July 11, 2018 Еще одна страница, где хотелось бы отсортировать названия групп маркеров по названию. Так там Membermap, а мы тут о Musicbox говорим. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now