There are three references to sorting (by status, email address, name), by default - all in ascending order. How to effectively make it so that when you are on any page with the selected sorting (be it /sort/status_desc/ or /sort/status_asc/) , the corresponding button changed its link to the opposite , i.e. to sort by decrease?
I am on /sort/status_desc/ - the link changes to /sort/status_asc/ .
This is what I did, but I consider this code ineffective, because it takes too much space if you screw it to each <div> link with classes:
Сортировать по: <?php if($sort == 'status_asc'): ?> <a href="/sort/status_desc/">Статусу</a> <a href="/sort/email_asc/">Эл. Почте</a> <a href="/sort/name_asc/">Имени</a> <?php endif;?> <?php if($sort == 'email_asc'): ?> <a href="/sort/status_asc/">Статусу</a> <a href="/sort/email_desc/">Статусу</a> <a href="/sort/name_asc/">Имени</a> <?php endif;?> <?php if($sort == 'name_asc'): ?> <a href="/sort/status_asc/">Статусу</a> <a href="/sort/email_asc/">Эл. Почте</a> <a href="/sort/name_desc/">Статусу</a> <?php endif;?> // еще 3 проверки на сортировки убыванием (sort_desc) <?php if(!isset($sort)): ?> <a href="/sort/status_asc/">Статусу</a> <a href="/sort/email_asc/">Эл. Почте</a> <a href="/sort/name_asc/">Имени</a> <?php endif;?>