• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Add Secondary Top Control?

Jaxel

Well-known member
#1
I have been using template hooks to add top control buttons. It worked great in the past with "threads"; now I am trying to add a top control to a forum... With the thread it worked great, but threads don't have their own top controls. With the forum, its not working at all... I assume its because the forum already has a top control and you can't add a second one? Is it possible to add a second top control?

Code:
<?php

class EWRatendo_Listener_Template
{
	public static function template_hook($name, &$contents, array $params, XenForo_Template_Abstract $template)
	{
		if ($name === 'forum_view_pagenav_before')
		{
			$contents .= $template->create('EWRatendo_ForumView', $params)->render();
		}
	}
}
Code:
<xen:topctrl>
	<a href="{xen:link 'events/create/{$forum.node_id}'}" class="callToAction">
		<span>{xen:phrase post_new_event}</span>
	</a>
</xen:topctrl>
 

xfrocks

Well-known member
#5
I did find a way to change the top controls section by listening to `template_post_render` and make the necessary change to $containerData (it's an array passed by reference so you can freely do whatever you want). Something like this

PHP:
if ('forum_view' == $templateName) {
$containerData['topctrl'] .= '<a href="link-to-my-page" class="callToAction"><span>Click Me!</span></a>';
}