Filter and Order threads (posts) by date and other features
Quote from Fillipe on July 27, 2017, 4:55 amHello all,
I will be working on changes on Asgaros plugin. My goal is to achieve something like this forum https://www.godlikeproductions.com/ both for looks and functionalities.
A believe major changes will be
1 – Filter threads by date – As you can see, you can navigate by clicking on “Previous Day” to change the post date of the threads displayed.
2 – A rating system will have to be developed also (this is something I’ve already mentioned and got help on another thread here).
I guess I am posting this here so that someone can tell me if there are any hooks I can use or where could I find the code I need to change.
For example, in includes/forum.php
function get_posts() { $start = $this->current_page * $this->options['posts_per_page']; $end = $this->options['posts_per_page']; $order = apply_filters('asgarosforum_filter_get_posts_order', 'p1.id ASC'); $results = $this->db->get_results($this->db->prepare("SELECT p1.id, p1.text, p1.date, p1.date_edit, p1.author_id, p1.author_edit, (SELECT COUNT(*) FROM {$this->tables->posts} AS p2 WHERE p2.author_id = p1.author_id) AS author_posts, p1.uploads FROM {$this->tables->posts} AS p1 WHERE p1.parent_id = %d ORDER BY {$order} LIMIT %d, %d;", $this->current_topic, $start, $end)); $results = apply_filters('asgarosforum_filter_get_posts', $results); return $results; }The query does not filter by dates (let’s say I want posts posted yesterday). I would have to change it here to begin with, right?
Also, as far as design goes, I will have to start on includes/views I suppose?
if ($counter_total > 0) { echo '<div class="title-element">'; echo __('Topics', 'asgaros-forum'); echo '<span class="last-post-headline">'.__('Last post', 'asgaros-forum').'</span>'; echo '</div>';includes/views/forum.php is where I will be adding the new columns (and then topic-element.php for each row in the table)?
I am sorry for posting so many questions. I am new to Asgaros Forum and I believe that asking those with more experience is a good way to begin developing for this plugin.
Hello all,
I will be working on changes on Asgaros plugin. My goal is to achieve something like this forum https://www.godlikeproductions.com/ both for looks and functionalities.
A believe major changes will be
1 – Filter threads by date – As you can see, you can navigate by clicking on “Previous Day” to change the post date of the threads displayed.
2 – A rating system will have to be developed also (this is something I’ve already mentioned and got help on another thread here).
I guess I am posting this here so that someone can tell me if there are any hooks I can use or where could I find the code I need to change.
For example, in includes/forum.php
function get_posts() { $start = $this->current_page * $this->options['posts_per_page']; $end = $this->options['posts_per_page']; $order = apply_filters('asgarosforum_filter_get_posts_order', 'p1.id ASC'); $results = $this->db->get_results($this->db->prepare("SELECT p1.id, p1.text, p1.date, p1.date_edit, p1.author_id, p1.author_edit, (SELECT COUNT(*) FROM {$this->tables->posts} AS p2 WHERE p2.author_id = p1.author_id) AS author_posts, p1.uploads FROM {$this->tables->posts} AS p1 WHERE p1.parent_id = %d ORDER BY {$order} LIMIT %d, %d;", $this->current_topic, $start, $end)); $results = apply_filters('asgarosforum_filter_get_posts', $results); return $results; }
The query does not filter by dates (let’s say I want posts posted yesterday). I would have to change it here to begin with, right?
Also, as far as design goes, I will have to start on includes/views I suppose?
if ($counter_total > 0) { echo '<div class="title-element">'; echo __('Topics', 'asgaros-forum'); echo '<span class="last-post-headline">'.__('Last post', 'asgaros-forum').'</span>'; echo '</div>';
includes/views/forum.php is where I will be adding the new columns (and then topic-element.php for each row in the table)?
I am sorry for posting so many questions. I am new to Asgaros Forum and I believe that asking those with more experience is a good way to begin developing for this plugin.
Quote from Fillipe on July 27, 2017, 6:03 amJust found these hooks that I believe will be useful:
+* Added: asgarosforum_custom_forum_column hook +* Added: asgarosforum_custom_topic_column hookhttps://github.com/Asgaros/asgaros-forum/commit/2a51b355eeb8dc9bdfc204d40ed7a416c5fbd6df
=]
Just found these hooks that I believe will be useful:
+* Added: asgarosforum_custom_forum_column hook +* Added: asgarosforum_custom_topic_column hook
https://github.com/Asgaros/asgaros-forum/commit/2a51b355eeb8dc9bdfc204d40ed7a416c5fbd6df
=]
Quote from Yworld on July 27, 2017, 8:41 am
- asgarosforum_after_post_author
- asgarosforum_after_post_message
- asgarosforum_after_add_thread_submit
- asgarosforum_after_add_post_submit
- asgarosforum_after_edit_post_submit
- asgarosforum_{current_view}_custom_content_top
- asgarosforum_{current_view}_custom_content_bottom
- asgarosforum_editor_custom_content_bottom
- asgarosforum_statistics_custom_element
- asgarosforum_statistics_custom_content_bottom
- asgarosforum_admin_show_custom_category_data
- asgarosforum_before_delete_post
- asgarosforum_before_delete_topic
- asgarosforum_after_delete_post
- asgarosforum_after_delete_topic
- asgarosforum_custom_forum_column
- asgarosforum_custom_topic_column
- asgarosforum_after_first_post
- asgarosforum_filter_login_message
- asgarosforum_filter_post_username
- asgarosforum_filter_post_content
- asgarosforum_filter_post_shortcodes
- asgarosforum_filter_editor_settings
- asgarosforum_filter_get_posts
- asgarosforum_filter_get_threads
- asgarosforum_filter_get_posts_order
- asgarosforum_filter_get_threads_order
- asgarosforum_filter_notify_global_topic_subscribers_message
- asgarosforum_filter_notify_topic_subscribers_message
- asgarosforum_filter_insert_custom_validation
- asgarosforum_filter_subject_before_insert
- asgarosforum_filter_content_before_insert
- asgarosforum_filter_widget_title_length
- asgarosforum_subscriber_mails_new_post
- asgarosforum_subscriber_mails_new_topic
- asgarosforum_filter_subscribers_query_new_post
- asgarosforum_filter_subscribers_query_new_topic
- asgarosforum_filter_error_message_require_login
- asgarosforum_filter_user_groups_taxonomy_name
- asgarosforum_filter_avatar_size
- asgarosforum_after_post_author
- asgarosforum_after_post_message
- asgarosforum_after_add_thread_submit
- asgarosforum_after_add_post_submit
- asgarosforum_after_edit_post_submit
- asgarosforum_{current_view}_custom_content_top
- asgarosforum_{current_view}_custom_content_bottom
- asgarosforum_editor_custom_content_bottom
- asgarosforum_statistics_custom_element
- asgarosforum_statistics_custom_content_bottom
- asgarosforum_admin_show_custom_category_data
- asgarosforum_before_delete_post
- asgarosforum_before_delete_topic
- asgarosforum_after_delete_post
- asgarosforum_after_delete_topic
- asgarosforum_custom_forum_column
- asgarosforum_custom_topic_column
- asgarosforum_after_first_post
- asgarosforum_filter_login_message
- asgarosforum_filter_post_username
- asgarosforum_filter_post_content
- asgarosforum_filter_post_shortcodes
- asgarosforum_filter_editor_settings
- asgarosforum_filter_get_posts
- asgarosforum_filter_get_threads
- asgarosforum_filter_get_posts_order
- asgarosforum_filter_get_threads_order
- asgarosforum_filter_notify_global_topic_subscribers_message
- asgarosforum_filter_notify_topic_subscribers_message
- asgarosforum_filter_insert_custom_validation
- asgarosforum_filter_subject_before_insert
- asgarosforum_filter_content_before_insert
- asgarosforum_filter_widget_title_length
- asgarosforum_subscriber_mails_new_post
- asgarosforum_subscriber_mails_new_topic
- asgarosforum_filter_subscribers_query_new_post
- asgarosforum_filter_subscribers_query_new_topic
- asgarosforum_filter_error_message_require_login
- asgarosforum_filter_user_groups_taxonomy_name
- asgarosforum_filter_avatar_size
Quote from Asgaros on July 27, 2017, 10:40 amThe query does not filter by dates (let’s say I want posts posted yesterday). I would have to change it here to begin with, right?
Yes, those filters are for getting the posts.
includes/views/forum.php is where I will be adding the new columns (and then topic-element.php for each row in the table)?
You are right:
- forum.php is for the view when you are in a forum
- topic-element.php is a topic-element which is displayed inside the forum
So basically thats the place where to start. Feel free to ask if you have more questions. 🙂
The query does not filter by dates (let’s say I want posts posted yesterday). I would have to change it here to begin with, right?
Yes, those filters are for getting the posts.
includes/views/forum.php is where I will be adding the new columns (and then topic-element.php for each row in the table)?
You are right:
- forum.php is for the view when you are in a forum
- topic-element.php is a topic-element which is displayed inside the forum
So basically thats the place where to start. Feel free to ask if you have more questions. 🙂
Quote from Fillipe on July 28, 2017, 7:35 amQuote from Yworld on July 27, 2017, 8:41 am
- asgarosforum_after_post_author
- asgarosforum_after_post_message
- asgarosforum_after_add_thread_submit
- asgarosforum_after_add_post_submit
- asgarosforum_after_edit_post_submit
- asgarosforum_{current_view}_custom_content_top
- asgarosforum_{current_view}_custom_content_bottom
- asgarosforum_editor_custom_content_bottom
- asgarosforum_statistics_custom_element
- asgarosforum_statistics_custom_content_bottom
- asgarosforum_admin_show_custom_category_data
- asgarosforum_before_delete_post
- asgarosforum_before_delete_topic
- asgarosforum_after_delete_post
- asgarosforum_after_delete_topic
- asgarosforum_custom_forum_column
- asgarosforum_custom_topic_column
- asgarosforum_after_first_post
- asgarosforum_filter_login_message
- asgarosforum_filter_post_username
- asgarosforum_filter_post_content
- asgarosforum_filter_post_shortcodes
- asgarosforum_filter_editor_settings
- asgarosforum_filter_get_posts
- asgarosforum_filter_get_threads
- asgarosforum_filter_get_posts_order
- asgarosforum_filter_get_threads_order
- asgarosforum_filter_notify_global_topic_subscribers_message
- asgarosforum_filter_notify_topic_subscribers_message
- asgarosforum_filter_insert_custom_validation
- asgarosforum_filter_subject_before_insert
- asgarosforum_filter_content_before_insert
- asgarosforum_filter_widget_title_length
- asgarosforum_subscriber_mails_new_post
- asgarosforum_subscriber_mails_new_topic
- asgarosforum_filter_subscribers_query_new_post
- asgarosforum_filter_subscribers_query_new_topic
- asgarosforum_filter_error_message_require_login
- asgarosforum_filter_user_groups_taxonomy_name
- asgarosforum_filter_avatar_size
Quote from Asgaros on July 27, 2017, 10:40 amThe query does not filter by dates (let’s say I want posts posted yesterday). I would have to change it here to begin with, right?
Yes, those filters are for getting the posts.
includes/views/forum.php is where I will be adding the new columns (and then topic-element.php for each row in the table)?
You are right:
- forum.php is for the view when you are in a forum
- topic-element.php is a topic-element which is displayed inside the forum
So basically thats the place where to start. Feel free to ask if you have more questions.
Thanks again for both of you! This is very helpful and reassuring 🙂
Quote from Yworld on July 27, 2017, 8:41 am
- asgarosforum_after_post_author
- asgarosforum_after_post_message
- asgarosforum_after_add_thread_submit
- asgarosforum_after_add_post_submit
- asgarosforum_after_edit_post_submit
- asgarosforum_{current_view}_custom_content_top
- asgarosforum_{current_view}_custom_content_bottom
- asgarosforum_editor_custom_content_bottom
- asgarosforum_statistics_custom_element
- asgarosforum_statistics_custom_content_bottom
- asgarosforum_admin_show_custom_category_data
- asgarosforum_before_delete_post
- asgarosforum_before_delete_topic
- asgarosforum_after_delete_post
- asgarosforum_after_delete_topic
- asgarosforum_custom_forum_column
- asgarosforum_custom_topic_column
- asgarosforum_after_first_post
- asgarosforum_filter_login_message
- asgarosforum_filter_post_username
- asgarosforum_filter_post_content
- asgarosforum_filter_post_shortcodes
- asgarosforum_filter_editor_settings
- asgarosforum_filter_get_posts
- asgarosforum_filter_get_threads
- asgarosforum_filter_get_posts_order
- asgarosforum_filter_get_threads_order
- asgarosforum_filter_notify_global_topic_subscribers_message
- asgarosforum_filter_notify_topic_subscribers_message
- asgarosforum_filter_insert_custom_validation
- asgarosforum_filter_subject_before_insert
- asgarosforum_filter_content_before_insert
- asgarosforum_filter_widget_title_length
- asgarosforum_subscriber_mails_new_post
- asgarosforum_subscriber_mails_new_topic
- asgarosforum_filter_subscribers_query_new_post
- asgarosforum_filter_subscribers_query_new_topic
- asgarosforum_filter_error_message_require_login
- asgarosforum_filter_user_groups_taxonomy_name
- asgarosforum_filter_avatar_size
Quote from Asgaros on July 27, 2017, 10:40 amThe query does not filter by dates (let’s say I want posts posted yesterday). I would have to change it here to begin with, right?
Yes, those filters are for getting the posts.
includes/views/forum.php is where I will be adding the new columns (and then topic-element.php for each row in the table)?
You are right:
- forum.php is for the view when you are in a forum
- topic-element.php is a topic-element which is displayed inside the forum
So basically thats the place where to start. Feel free to ask if you have more questions.
Thanks again for both of you! This is very helpful and reassuring 🙂