I'm wondering about a bbcode tag for xenforo based on post position.
The following code is the link to a post in the upper right of each post container.
<a href="{{ link('threads/post', $thread, {'post_id': $post.post_id}) }}" rel="nofollow">
#{{ number($post.position + 1) }}</a>
I'm looking for bbcode (or an add-on as relevant) that takes ($post.position + 1) as an argument, finds that post in the thread via the $thread.posts array, then creates a link to that post via $post.post_id.
For example, if the post is this post, I'm looking for:
[post=1]Blah[/post] OR [post]1[/post]
to become
respectively.
Based on some discussion with a friend of my site who is more php-knowledgeable than I am, the following would be a start on simple implementation on the php side of things:
Given that $thread_id is known from the post in which the link is included, how difficult would it be to implement such a function?
The following code is the link to a post in the upper right of each post container.
<a href="{{ link('threads/post', $thread, {'post_id': $post.post_id}) }}" rel="nofollow">
#{{ number($post.position + 1) }}</a>
I'm looking for bbcode (or an add-on as relevant) that takes ($post.position + 1) as an argument, finds that post in the thread via the $thread.posts array, then creates a link to that post via $post.post_id.
For example, if the post is this post, I'm looking for:
[post=1]Blah[/post] OR [post]1[/post]
to become
[URL='https://atelieraphelion.com/threads/advanced-bb-code-link-by-post.769/post-2593']Blah[/URL]
OR [URL='https://atelieraphelion.com/threads/advanced-bb-code-link-by-post.769/post-2593']1[/URL]
respectively.
Based on some discussion with a friend of my site who is more php-knowledgeable than I am, the following would be a start on simple implementation on the php side of things:
Code:
public function postlink($position)
{
$linked = $this->db()->fetchOne("
SELECT post_id
FROM xf_post
WHERE position = ? AND thread_id = ?
", $position-1, $thread_id);
$final_link = '<a href="' . $__templater->func('link', array('threads/post', $__vars['thread'], 'linked' => $__vars['post']['linked'], ), ), true) . '" rel="nofollow"> #' . $__templater->func('number', array($__vars['post']['position-1'], ), true) . '</a>'
return $final_link;
}
Given that $thread_id is known from the post in which the link is included, how difficult would it be to implement such a function?
Last edited: