Create a conversation button (publicControls - post )

Neil E.

Active member
I'd like to add a button labeled "conversation" that would sit beside "reply" when my users view a thread. The purpose is to directly open a conversation with a poster in the thread. The name of the poster would automatically load into the participant window.

There could be many posters and each would have a conversation button the same way as they each currently have a reply button. The new button would be a direct shortcut to the "start a new conversation" page.

My users are already able to do this with our current forum software and I want to offer the same convenience. I'm hoping Jake might have an idea on how to proceed.
 
This works although it doesn't check permission to be able to start a convo. Not sure if the info is exposed for the conversation permission in that template. I added it in the private controls simply because of space and looks. It checks if the user can report, if so they can start a convo.

Code:
<xen:if is="{$canStartConversation}">
<a href="{xen:link conversations/add, '', 'to={$post.username}'}">{xen:phrase start_conversation}</a>
</xen:if>

In post template add the line in red.

Rich (BB code):
<xen:include template="message">

	<xen:map from="$post" to="$message" />

	<xen:set var="$messageId">post-{$post.post_id}</xen:set>
	
	<xen:set var="$likesUrl">{xen:link posts/likes, $post}</xen:set>
	
	<xen:set var="$messageContentAfterTemplate"><xen:if is="{$post.attachments}"><xen:include template="attached_files" /></xen:if></xen:set>
	
	<xen:set var="$messageAfterTemplate">
				
		<div class="messageMeta">
			
			<div class="privateControls">
				<xen:if is="{$post.canInlineMod}"><input type="checkbox" name="posts[]" value="{$post.post_id}" class="InlineModCheck item" data-target="#post-{$post.post_id}" title="{xen:phrase select_this_post_by_x, 'name={$post.username}'}" /></xen:if>
				<span class="item muted">
					<xen:username user="$post" class="author" />,
					<a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="datePermalink"><xen:datetime time="$post.post_date" /></a>
				</span>
				<xen:hook name="post_private_controls" params="{xen:array 'post={$post}'}">
				<xen:if is="{$post.canEdit}">
					<a href="{xen:link posts/edit, $post}" class="item control edit {xen:if $xenOptions.messageInlineEdit, OverlayTrigger}"
						data-href="{xen:link posts/edit-inline, $post}" data-overlayOptions="{&quot;fixed&quot;:false}"
						data-messageSelector="#post-{$post.post_id}"><span></span>{xen:phrase edit}</a>
					<xen:require js="js/xenforo/discussion.js" />
				</xen:if>
				<xen:if is="{$post.canDelete}"><a href="{xen:link posts/delete, $post}" class="item control delete OverlayTrigger"><span></span>{xen:phrase delete}</a></xen:if>
				<xen:if is="{$post.canCleanSpam}"><a href="{xen:link spam-cleaner, $post}" class="item control deleteSpam OverlayTrigger"><span></span>{xen:phrase spam}</a></xen:if>
				<xen:if is="{$canViewIps} AND {$post.ip_id}"><a href="{xen:link posts/ip, $post}" class="item control ip OverlayTrigger"><span></span>{xen:phrase ip}</a></xen:if>
				
				<xen:if is="{$post.canWarn}">
					<a href="{xen:link members/warn, $post, 'content_type=post', 'content_id={$post.post_id}'}" class="item control warn"><span></span>{xen:phrase warn}</a>
				<xen:elseif is="{$post.warning_id} && {$canViewWarnings}" />
					<a href="{xen:link warnings, $post}" class="OverlayTrigger item control viewWarning"><span></span>{xen:phrase view_warning}</a>
				</xen:if>
				<xen:if is="{$post.canReport}">
					<a href="{xen:link posts/report, $post}" class="OverlayTrigger item control report" data-cacheOverlay="false"><span></span>{xen:phrase report}</a>
					<a href="{xen:link conversations/add, '', 'to={$post.username}'}">{xen:phrase start_conversation}</a>
				</xen:if>
				
				</xen:hook>
			</div>
			
			<div class="publicControls">
				<a href="{xen:link threads/post-permalink, $thread, 'post={$post}'}" title="{xen:phrase permalink}" class="item muted postNumber hashPermalink OverlayTrigger" data-href="{xen:link posts/permalink, $post}">#{xen:calc '{$post.position} + 1'}</a>
				<xen:hook name="post_public_controls" params="{xen:array 'post={$post}'}">
				<xen:if is="{$post.canLike}">
					<a href="{xen:link posts/like, $post}" class="LikeLink item control {xen:if $post.like_date, unlike, like}" data-container="#likes-post-{$post.post_id}"><span></span><span class="LikeLabel">{xen:if $post.like_date, {xen:phrase unlike}, {xen:phrase like}}</span></a>
				</xen:if>
				<xen:if is="{$canReply}">
					<a href="{xen:link threads/reply, $thread, 'quote={$post.post_id}'}" data-postUrl="{xen:link posts/quote, $post}" class="ReplyQuote item control reply" title="{xen:phrase reply_quoting_this_message}"><span></span>{xen:phrase reply}</a>
				</xen:if>
				</xen:hook>
			</div>
		</div>
	</xen:set>
	
</xen:include>
 
I like Qwk86gn's template edit for simplicity, but Ragtek's addon has the permissions tie in. I've installed it and it works as advertised.

Thank you Ragtek.
 
Actually this was more of a comment to say "I prefer template edits to addons" due to my current experience level.

With a template edit I can see exactly what's been altered and can document it easily via TMS. Simple and quick to do.

With an addon I cross my fingers and hope for the best (only because addons are still something of a mystery to me).
It's more work to install an addon, but I'm getting better at it.

Which method is better when it comes time to upgrade forum software?
 
You would require more steps to update templates using my method. Whether it is with TMS or without. TMS you still have to select rebuild template modifications after a upgrade.

The add-on, with this particular add-on I don't see why it would ever really be an issue on an upgrade, meaning it shouldn't break anything and you can also easily disable it in the add-on list if you are having problems, instead of having to search the TMS to disable ect..
 
Top Bottom