Add-on Start conversation from post

Paul

Well-known member
There used to be under xf1 an add-on which would allow a user to create a conversation from a post just by clicking on a small text link at the bottom of each post. This would create a pm with the same title as the thread to the person that wrote that post.

It would also quote the post you were replying to.

Can’t remember the name of it now (still looking), however does anyone know of any functionality like this that exists in an xf2 add-on, or alternatively anyone interested in coding this?

Cheers
Paul
 
however does anyone know of any functionality like this that exists in an xf2 add-on


Edit: Ah, maybe it doesn't quote the post.
 

Edit: Ah, maybe it doesn't quote the post.

Hopefully if I ask nicely the op will add it :)
 
If you don't want to use an add-on, just edit the post_macros template and add this on line 139:
HTML:
<xf:if is="$xf.visitor.canStartConversationWith($post.User)">
    <xf:button href="{{ link('conversations/add', null, {'to': $post.User.username}) }}" class="button--link">
        {{ phrase('start_conversation') }}
    </xf:button>
</xf:if>

199730

199731
 
I missed the thread title.

HTML:
<xf:if is="$xf.visitor.canStartConversationWith($post.User)">
    <xf:button href="{{ link('conversations/add', null, {'to': $post.User.username, 'title': $thread.title}) }}" class="button--link">
        {{ phrase('start_conversation') }}
    </xf:button>
</xf:if>
 
I missed the thread title.

HTML:
<xf:if is="$xf.visitor.canStartConversationWith($post.User)">
    <xf:button href="{{ link('conversations/add', null, {'to': $post.User.username, 'title': $thread.title}) }}" class="button--link">
        {{ phrase('start_conversation') }}
    </xf:button>
</xf:if>

Any way to get it to add the content of that post to the conversation too Paul? Or am I just being over-optimistic here 😂
Also, any way to make that a text link rather than a button - only so it matches its surroundings :)

Much prefer this way than an add-on - cleaner :)
 
XF doesn't have a built in method for prepopulating the content field.

I'm not at a computer so can't check but you can change the styling to suit by altering the xf:button to a basic a href and the button--link class to something else.
You can likely use the same class used for the other links.
 
I'm interested in getting the post quoted as well.

XF doesn't have a built in method for prepopulating the content field.

So this XF1 addon quoted the post into the message body from scratch?
 
If you don't want to use an add-on, just edit the post_macros template and add this on line 139:
HTML:
<xf:if is="$xf.visitor.canStartConversationWith($post.User)">
    <xf:button href="{{ link('conversations/add', null, {'to': $post.User.username}) }}" class="button--link">
        {{ phrase('start_conversation') }}
    </xf:button>
</xf:if>

View attachment 199730

View attachment 199731
If i do this an error follows:
Server-Fehlerprotokoll
  • TypeError: Argument 1 passed to XF\Entity\User::canStartConversationWith() must be an instance of XF\Entity\User, null given
  • src/XF/Entity/User.php:828

  • Generiert von: Unbekanntes Konto
  • 7 September 2019 um 20:17

Stack-Trace
#0 [internal function]: XF\Entity\User->canStartConversationWith(NULL)
#1 src/XF/Template/Templater.php(999): call_user_func_array(Array, Array)
#2 internal_data/code_cache/templates/l2/s1/public/post_macros.php(240): XF\Template\Templater->method(Object(SV\ReportImprovements\XF\Entity\User), 'canStartConvers...', Array)
#3 src/XF/Template/Templater.php(701): XF\Template\Templater->{closure}(Object(SV\UserActivity\XF\Template\Templater), Array, Array)
#4 internal_data/code_cache/templates/l2/s1/public/thread_view.php(655): XF\Template\Templater->callMacro('post_macros', 'post', Array, Array)
#5 src/XF/Template/Templater.php(1315): XF\Template\Templater->{closure}(Object(SV\UserActivity\XF\Template\Templater), Array)
#6 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate('thread_view', Array)
#7 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#8 src/XF/Mvc/Dispatcher.php(418): XF\Mvc\Renderer\Html->renderView('XF:Thread\\View', 'public:thread_v...', Array)
#9 src/XF/Mvc/Dispatcher.php(400): XF\Mvc\Dispatcher->renderView(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#10 src/XF/Mvc/Dispatcher.php(360): XF\Mvc\Dispatcher->renderReply(Object(XF\Mvc\Renderer\Html), Object(XF\Mvc\Reply\View))
#11 src/XF/Mvc/Dispatcher.php(53): XF\Mvc\Dispatcher->render(Object(XF\Mvc\Reply\View), 'html')
#12 src/XF/App.php(2178): XF\Mvc\Dispatcher->run()
#13 src/XF.php(390): XF\App->run()
#14 index.php(20): XF::runApp('XF\\Pub\\App')
#15 {main}
 
If i do this an error follows:
It could be because you have allowed anonymous user to post thread on your forum and as your post don't have user in XF database so it would cause error when you call it using User relation with post param. Any way you can resolve this by adding following code:

Code:
<xf:if is="$post.User AND $xf.visitor.canStartConversationWith($post.User) ">
          <xf:button href="{{ link('conversations/add', null, {'to': $post.User.username}) }}" class="button--link">
              {{ phrase('start_conversation') }}
         </xf:button> 
</xf:if>
 
If you don't want to use an add-on, just edit the post_macros template and add this on line 139:
HTML:
<xf:if is="$xf.visitor.canStartConversationWith($post.User)">
    <xf:button href="{{ link('conversations/add', null, {'to': $post.User.username}) }}" class="button--link">
        {{ phrase('start_conversation') }}
    </xf:button>
</xf:if>

View attachment 199730

View attachment 199731


How can I put the button above the action bar?

1700726115036.webp
 
Back
Top Bottom