staleo |
|
---|---|
Hi all, I got a question on how to sort the pages with the same tag. In the plugin settings, there are four options to choose from: to sort pages by id, by date, by title, and by category. Dear community, how do I sort the pages by begin date? Thanks in advance, Cheers. |
Macik |
|
---|---|
This functionallity is hard coded in Tags plugin. So you can not alter it simply with settings. But it's a flexible enough to be extended with other plugin for this. So you can write simple plugin with 2 hooks:
// check is it possible to sort by this field if ($db->fieldExists($db_pages,'page_'.$o)) { $order = 'ORDER BY `page_'.$o.'`'; }
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
staleo |
|
---|---|
Macik, Thank you for the info, but unfortunately I lack the experience of writing the plugins, as well as have a rather weak understanding of what you imply by hooks, and how the latter deal with the former. If this doesn't bother you, can you please explain how do I implement your solution step by step? I'd appreciate it a lot! Thank you again. |
Macik |
|
---|---|
Making plugins is just a piece of cake: Look at here, check readme, download it and install — this is magic box for plugin creation. Then let's create our simple plugin — look at this http://screenshot.galaxyhost.org/img/20140428-75f-72kb.jpg :
Press «Create extension files». Magic is done. Now we should work a little: Locate files in `plugins/extension_template/created/tagsort`, copy it to plugins folder as usual plug. Open our generated files (`tagsort.first.php` and `tagsort.pages.query.php`), fix hook names and add corresponding code: It's never been so easy. :) Some code explanation (see post above):
https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
staleo |
|
---|---|
Macik, Thank you for a such a broad descriprion of how your plugin works, but anyway, for some reason, your solution didn't work for me properly. Here's the tagsort plugin http://joxi.ru/nNheUxjKTJByDnIHAZc — that seems, the tags.first hook simply doesn't correspond with the Tags plugin settings. There are 4 options of how to sort the pages, just like it used to be, no "Author", no "Begin date", nothing. I could of course make some mistake, and your help with it would be very much appreciated. Above that, if you don't mind, I found an issue, which could be rather important for your plugin users, particularly for those like me, lacking the experience of writing plugins for their needs. Right after filling up the second section, "Misc", I found out that clicking "Submit" simply doesn't change anything. No output, no answer, the button just leaves everything how it was. I tried refilling the data 3 or 4 times, before I cought what was wrong. The issue here is that user doesn't know where exactly plugin tries to create a subfolder /created. The right answer is: in /datas, but who knows that? :) Therefore, this could be a good idea to give user a short hint, like, "Make /datas writable, we will do the rest", or something. |
Macik |
|
---|---|
It's quite strange. I had checked you archive and it works fine for me — http://screenshot.galaxyhost.org/img/20140501-5q3-35kb.jpg What about versions that you use (Cotonti and Tags plugin)? I use Siena version and Version=0.9.14 of `Tags` plugin
Thank you for your opinion. First of all. it should be displayed Log message (like here: http://screenshot.galaxyhost.org/img/20140501-bpb-62kb.jpg ) https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
staleo |
|
---|---|
Macik, Of course I messed everything up. :)
For some reason, I thought you imply the sorting values in the Tags plugin settings (http://domain.com/admin/config?n=edit&o=plug&p=tags), while in fact you were meaning the sorting options on the actual tags output page (http://domain.com/tags/bla-bla-tah-here). Now it's all fine, it works. But I was actually planning to hide the sorting options, just leaving the "By begin date" as a default method of sorting pages. Are there any ways of doing so? Thank you in advance! Добавлено 4 минуты спустя: Macik, Also, if you have any ideas on another Tags issue, welcome! Here's the topic: http://www.cotonti.com/forums?m=posts&q=7730. |
Macik |
|
---|---|
This way it's faster to do it via edit template `tags.tpl` and replace: <select name="order"> <option value="">{PHP.L.tags_Orderby}</option> <option value="">--</option> {TAGS_ORDER} </select> with: <input type="hidden" name="order" value="begin" /> Then you can stop `tags.first` part of plugin, leaving only `tagsort.pages.query`.
I'll check it later. https://github.com/macik
правильный хостинг — https://goo.gl/fjCa1F |
staleo |
|
---|---|
All right, here's the solution we found. 1. In a table cot_config we search a required setting with a query: SELECT * 2. Here we add a required field. If you need to sort pages by page_begin, just add begin (without page_). 3. Here we go! In the Tags plugin settings, find a dropdown menu with the options how to sort pages with the same tag. Choose Begin. Voila! For this short manual, we send deepest thanks to Nastya Kizza. :) p.s. Thx to Macik anyway! |