I've been struggling with this for a few days now but just can't seem to get it to work.
Basically I am trying to get a template to show on the forum index, based on a global permission.
Something like this:
The template is cta_featuredthreads_block and the contents are wrapped in: <xen:if is="{$canViewFeaturedThreads}">...</xen:if>.
The permissions is set to allow:
If I change the xen:if in the template to <xen:if is="{$visitor.permissions.ctaFt.ctaFtViewFeaturedThreads}"> then it works, so I know my permission and template modification are all working.
This is what my library\CTA\FeaturedThreads\Listener.php looks like:
And my library\CTA\FeaturedThreads\Model\Featured.php:
Finally, this is my library\CTA\FeaturedThreads\ControllerPublic\Forum.php:
If I had any hair I would have ripped it out by now...
Does anyone have any clues as to why it's not working?
Thanks.
Basically I am trying to get a template to show on the forum index, based on a global permission.
Something like this:
The template is cta_featuredthreads_block and the contents are wrapped in: <xen:if is="{$canViewFeaturedThreads}">...</xen:if>.
The permissions is set to allow:
If I change the xen:if in the template to <xen:if is="{$visitor.permissions.ctaFt.ctaFtViewFeaturedThreads}"> then it works, so I know my permission and template modification are all working.
This is what my library\CTA\FeaturedThreads\Listener.php looks like:
Code:
<?php
class CTA_FeaturedThreads_Listener
{
public static function extendForumController ($class, array &$extend)
{
if ($class == 'XenForo_ControllerPublic_Forum')
{
$extend[] = 'CTA_FeaturedThreads_ControllerPublic_Forum';
}
}
}
And my library\CTA\FeaturedThreads\Model\Featured.php:
Code:
<?php
class CTA_FeaturedThreads_Model_Featured extends XenForo_Model
{
public function canViewFeaturedThreads(array $viewingUser = null)
{
$this->standardizeViewingUserReference($viewingUser);
if (XenForo_Permission::hasPermission($viewingUser['permissions'], 'ctaFt', 'ctaFtViewFeaturedThreads'))
{
return true;
}
return false;
}
}
Finally, this is my library\CTA\FeaturedThreads\ControllerPublic\Forum.php:
Code:
<?php
class CTA_FeaturedThreads_ControllerPublic_Forum extends XFCP_CTA_FeaturedThreads_ControllerPublic_Forum
{
public function actionIndex()
{
$parent = parent::actionIndex();
$forum = $parent->params['forum'];
$featureThreadModel = XenForo_Model::create('CTA_FeaturedThreads_Model_Featured');
$parent->params['canViewFeaturedThreads'] = $featureThreadModel->canViewFeaturedThreads($forum);
return $parent;
}
}
If I had any hair I would have ripped it out by now...
Does anyone have any clues as to why it's not working?
Thanks.