Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with stacked forum in last post #10

Closed
soft4tec opened this issue Oct 15, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@soft4tec
Copy link

commented Oct 15, 2015

If you have subforums in your forum there is an in the link for the last post.
For Example

  • Forum 1
    • SubForum
      • FirstPost

I found an quick&dirty solution in the listener.php for the function:

public function display_forums_modify_template_vars($event)

Replace the line:

$url = $this->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);

with:

                $sql = 'SELECT p.post_id, p.topic_id, p.forum_id, f.forum_name
                        FROM ' . POSTS_TABLE . ' AS p
                        LEFT JOIN ' . FORUMS_TABLE . ' AS f
                        ON f.forum_id = p.forum_id
                        WHERE ' . $db->sql_build_array('SELECT', array('post_id'    => $event['row']['forum_last_post_id']));
                $result = $db->sql_query($sql);
                $LastPostRow = $db->sql_fetchrow($result);
                $db->sql_freeresult($result);
                $url = $this->generate_topic_link($LastPostRow['forum_id'], $LastPostRow['forum_name'], $LastPostRow['topic_id'], $event['row']['forum_last_post_subject']);

Maybe there is a better way to get the title and ids, but this works for the first.

@Sarr

This comment has been minimized.

Copy link

commented Oct 18, 2015

@soft4tec sorry but it doesn't work for me.
I get: "Fatal error: Call to a member function sql_build_array() on a non-object in /home/sarr/public_html/forum.swordcoast.pl/ext/tas2580/seourls/event/listener.php on line 184"

There are 2 occurance of
'$url = $this->generate_topic_link($event['row']['forum_id'], $event['row']['forum_name'], $event['row']['topic_id'], $event['row']['topic_title']);'

First is in "public function search_modify_tpl_ary($event)"
I changed only the second one, as you wrote. (under display_forums_modify_template_vars)

@soft4tec

This comment has been minimized.

Copy link
Author

commented Oct 19, 2015

Oh sorry,
I forget the

global $db;

to access the Database-Object in the function. Then it should be work.

@tas2580 tas2580 closed this in d28a431 Oct 20, 2015

@tas2580

This comment has been minimized.

Copy link
Owner

commented Oct 20, 2015

Thanks for reporting, but your solution has the problem that it will make a lot of SQL queries. I have found a better way without additional SQL queries. I hope it will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.