Advanced BB Code - Link By Post

osieorb18

Member
Reactions
1
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

[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:
I do not have plans to add this to the advanced bb-code add-on.

This is already part of one of my free add-ons;

I don't really want to copy the code-base and I'm reluctant to remove a free add-on to make it part of a paid add-on without a legitimate reason (ie rewriting from XF1.x to XF2.x level change).

On the upside your feature already exists!
 
I do not have plans to add this to the advanced bb-code add-on.

This is already part of one of my free add-ons;

I don't really want to copy the code-base and I'm reluctant to remove a free add-on to make it part of a paid add-on without a legitimate reason (ie rewriting from XF1.x to XF2.x level change).

On the upside your feature already exists!

How simple would it be to make a variant on the add-on which links by position using a query on the posts in the thread?
 

Users who are viewing this thread

Back
Top