Please can you tell me how to order the ticket posts so the most recent reply is always shown first on individual ticket views on the front end.
Regards,
Andrew
Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.
Latest post by realvisioninternet on Tuesday, 28 February 2023 22:45 CST
Please can you tell me how to order the ticket posts so the most recent reply is always shown first on individual ticket views on the front end.
Regards,
Andrew
There is no such option, nor are we willing to add one. Posts are always displayed chronologically (oldest first) and the reply area, if necessary, appears after the latest post.
The reply area placement is the reason why we are not going to give you an option to reverse the post order. If posts appear reverse chronologically (oldest first) where does the reply area fit in? If it's at the bottom of the page it's right after the oldest reply which is confusing and requires a lot of back and forth between the top of the page (latest reply) and the bottom of the page (reply area) to compose a reply. If you put it at the very top so it's adjacent to the latest reply then the interface is weird; the first thing you see is a blank reply area, then the actual content. If you put it right after the first displayed (latest) post the interface looks like it was designed with crayons, to put it charitably. There is no good, intuitive solution. Therefore, if we were to add support for reversing the post orders we'd have to constantly defend the "wrong" placement of the reply area even though we both disagree with having the posts in reverse chronological order (it's counter-intuitive) and know that there is no "right" placement of the reply area. In short, we are not going to give you an option which will only cause complaints, we know why it will cause complaints, and we actually agree with the reason for the complaints. It would make no sense; we're developers, not politicians.
If you absolutely want to change the post order, sure you can, with standard Joomla! template overrides. Create a template override for components/com_ats/tmpl/ticket/default.php
. Line 22 reads
$posts = $this->item->posts($this->item->id);
Right after it, put the code:
$posts = array_reverse($posts, true);
This will reverse the posts order. It will not move the reply area. If you think this interface makes sense in your use case, go for it.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!
Hello,
can you please tell me in which view you would like to see that? Inside the category view, the Latest Tickets, My Tickets etc etc
Davide Tampellini
Developer and Support Staff
🇮🇹Italian: native 🇬🇧English: good • 🕐 My time zone is Europe / Rome (UTC +1)
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!
Thanks Davide, I was referring to a ticket view like this page.
Nicholas, thanks for the reply, I understand what you are saying and maybe a scroll to the last post would be a useful option either automatically or as a button.
Reversing the order in my case is better as some tickets have many replies, and the override with $posts = array_reverse($posts, true); works fine.
I also moved the reply area to the top in the same file.
Regards,
Andrew
Stupid question (so I can understand your request better): is there a reason not to use the browser's scrollbar or, on devices with keyboards, the End key instead of adding a link to the last post?
Also, second question related to the first. When you receive an email notification either as a client or as support staff, the link is to the last post. What is the use case where you'd visit the ticket and need to directly scroll to the last post without using the scrollbar or the keyboard?
I am pretty sure there is a valid use case here, I need you to help me understand it so I know exactly what problem I am trying to solve.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!
In my use case each ticket category is a project containing multiple tickets, there are very few users with access (typically one or two users per category) but many tickets each with multiple replies.
There are usually multiple tickets open in each category and the majority of tickets are accessed by the category view page and not via the email. Using the browser's scrollbar is slow with a long page and the End key takes the user to the end of the last post not the beginning of the last post.
For me it's better now I have the override with the reply at the top, no manager notes and the latest reply first but I do think a button would be useful as an alternative to the override I implemented.
Regards,
Andrew
Ah, I understand the use case perfectly well now. Thank you!
We do have some tickets which go on forever but they were never in such ample supply to warrant a special consideration. In your use case that's the norm rather than the exception. Fair enough.
I tried a few different ways to implement your suggestion. Buttons look out of place, but a simple link above the very first post seems to be unobtrusive and effective. Edit the same file I told you before. After line 85 (before the line with the foreach) add the following:
<?php if (count($posts) > 1): $lastPost = $posts[array_key_last($posts)]; ?> <p class="ats-post-last text-muted small text-end"> <a href="https://www.akeeba.com/#p<?= $lastPost->id?>" class="link-secondary"> <span class="fa fa-angle-double-down" aria-hidden="true"></span> <?= Text::sprintf( 'COM_ATS_TICKETS_MSG_LASTPOST', Factory::getContainer() ->get(\Joomla\CMS\User\UserFactoryInterface::class) ->loadUserById($lastPost->created_by)->username, HTMLHelper::_('ats.date', $lastPost->created, Text::_('DATE_FORMAT_LC2')) ) ?> </a> </p> <?php endif ?>
If there are more than one posts in the ticket it will display a right aligned link above the header of the first post reading something like “Latest post by client on Thursday, 19 January 2023 09:52 EET”. Clicking on it will make the browser scroll to the header of the last post in the ticket.
The trick here is that every header has an ID attribute of "p1234" where 1234 is the monotonically increasing post ID across all tickets. Telling the browser to open "#p1234" makes it scroll to the element with that ID attribute (minus the hash sign) — that's called a URL fragment and it's been available for literal decades, since the early versions of web browsers in the 90s.
Please tell me if that works for your use case.
Nicholas K. Dionysopoulos
Lead Developer and Director
🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!
Nicholas,
Sorry for the late reply, thanks this works great and I'm using it, I can see you are too!
Regards,
Andrew
Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.
Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!