×
Blue Eagle (1.5.0) for K5.1 is released (20 Jul 2018)

Please update the Kunena Blue Eagle to 1.5.0 if you use Kunena 5.1.
We made several bug fixes and improvements. Also Blue Eagle has now all the features from Crypsis.
Download: www.kunena.org/download/templates/category/blue-eagle-5

× Please note: The Kunena project team takes NO responsibility for maintaining nor supporting anything in this category.

Loved Subscribe button on front page

More
5 years 1 week ago - 5 years 1 week ago #1 by MusicInMe
Well, hope I get help because this is getting on top of me. I added Subscribe button on the front page to allow user do this without open category where this button is usualy placed.
<?php if ($this->category->authorise ( 'subscribe', null, true )) :
  $subscribed = $this->category->getSubscribed($this->me->userid);
  if (!$subscribed) { ?>
 
 <a class="hasTooltip" href="index.php?option=com_kunena&view=category&task=subscribe&catid=<?php echo $category->id; ?><?php echo $token; ?>" title="<?php echo JText::_('COM_KUNENA_TEMPLATE_SUBSCRIBE_NOW'); ?>" >
  <button class="btn btn-warning btn-small">
    <i class="icon-white icon-envelope"></i>
  </button>
 </a> 
 
<?php }; ?>
<?php else: ?>
 
 <a class="hasTooltip" href="index.php?option=com_kunena&view=category&task=unsubscribe&catid=<?php echo $category->id; ?><?php echo $token; ?>" title="<?php echo JText::_('COM_KUNENA_TEMPLATE_UNSUBSCRIBE'); ?>">
  <button class="btn btn-warning btn-small">
    <i class="icon-white icon-envelope"></i>
  </button>
 </a>
 
<?php endif; ?>

This only show second option, as every category is already subscribed. At the beginning of file I placed
$token = '&' . JSession::getFormToken() . '=1';

but it doesn't help to identify user is alowed to su/unsubscribe. When I enter to category I am able to subscribe to any childforum this category contain. So need to figure out only front page.
Last edit: 5 years 1 week ago by MusicInMe.

Please Log in or Create an account to join the conversation.

More
5 years 1 week ago #2 by xillibit

MusicInMe wrote:
This only show second option, as every category is already subscribed. At the beginning of file I placed

$token = '&' . JSession::getFormToken() . '=1';

but it doesn't help to identify user is alowed to su/unsubscribe. When I enter to category I am able to subscribe to any childforum this category contain. So need to figure out only front page.

Hello,

The JSession::getFormToken() just set a token to avoid security problems.

To get the user id you can use by example :
JFactory::getUser()->id;

I don't provide support by PM, because this can be useful for someone else.

Please Log in or Create an account to join the conversation.

More
5 years 4 days ago #3 by MusicInMe
Wasn't easy but finaly got the solution:
Added code (just after
defined ( '_JEXEC' ) or die ();
at the top of let say in template/my_template/html/category/default.php
if ($this->category->authorise ( 'subscribe', null, true )) {
  $subscribed = $this->category->getSubscribed($this->me->userid);
  if (!$subscribed) {
    $subscription = "index.php?option=com_kunena&view=category&task=subscribe&catid={$this->category->id}{$token}";
	$substitle = "Subscribe";
	$tiptile = "Subscribe to category";
	} else {
	$subscription = "index.php?option=com_kunena&view=category&task=unsubscribe&catid={$this->category->id}{$token}";
	$substitle = "Unubscribe";
	$tiptitle = "Unsubscribe from category";
  }
}

and then, where the code must be shown
<a href="<?php echo $subscription; ?>" class="hasTooltip" title="<?php echo $tiptitle; ?>"><i class="icon-envelope"></i> <?php echo $substitle; ?></a>

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to add attachements.
  • Not Allowed: to edit your message.
Time to create page: 0.237 seconds