XF 2.3 Button link to edit post

PhineasD

Well-known member
I use @Siropu Ads Manager plugin to create buttons fixed to the footer that stay on screen when scrolling.

The code I use is very simple, for example:

Code:
<a href="./post-thread" aria-label="Comment thread">
<i class="far fa-reply" data-xf-init="icon"></i></a>

How can I add a link to the edit button? The problem I'm encountering is that it uses the post ID in the URL:

HTML:
https://xxxx.com/posts/11472/edit

I've tried the post_macros template code and it doesn't work. How can I fix it?

HTML:
<a href="{{ link('posts/edit', $post) }}">{{ phrase('edit') }}</a>
 
Solution
I tried this but it doesn't work:
I have tested it and it works, but in some thread types such as question, the first post in not the one that stated the thread so you need this instead:

Code:
<a href="{{ link('posts/edit', {'post_id': $xf.samParams.thread.first_post_id}) }}">
  <i class="far fa-edit"></i> {{ phrase('edit') }}
</a>
In my add-on I have added some params to access certain entities based on the page. For thread view, you can use:

$xf.samParams.posts|first
$xf.samParams.thread

Sorry, how can I insert it in my code?

I tried this but it doesn't work:

HTML:
<a href="{{ link('posts/edit', $xf.samParams.posts|first) }}">
  <i class="far fa-edit"></i> {{ phrase('edit') }}
</a>
 
Last edited:
I tried this but it doesn't work:
I have tested it and it works, but in some thread types such as question, the first post in not the one that stated the thread so you need this instead:

Code:
<a href="{{ link('posts/edit', {'post_id': $xf.samParams.thread.first_post_id}) }}">
  <i class="far fa-edit"></i> {{ phrase('edit') }}
</a>
 
Solution
Back
Top Bottom