- Posts: 52
- Thank you received: 3
Kunena 6.1.3.2 Released
The Kunena team has announce the arrival of Kunena 6.1.3.2 [K 6.1.3] which is now available for download as a native Joomla extension for J! 4.2.x/4.3.x. This version addresses most of the issues that were discovered in K 6.1.0 and issues discovered during the last development stages of K 6.1
Please note: The Kunena project team takes NO responsibility for maintaining nor supporting anything in this category.
Loved Subscribe button on front page
10 years 1 month ago - 10 years 1 month ago #1
by MusicInMe
Subscribe button on front page was created 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.
This only show second option, as every category is already subscribed. At the beginning of file I placed
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.
Code:
<?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
Code:
$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: 10 years 1 month ago by MusicInMe.
Please Log in or Create an account to join the conversation.
10 years 1 month ago #2
by xillibit
The JSession::getFormToken() just set a token to avoid security problems.
To get the user id you can use by example :
I don't provide support by PM, because this can be useful for someone else.
Replied by xillibit on topic Subscribe button on front page
Hello,MusicInMe wrote:
This only show second option, as every category is already subscribed. At the beginning of file I placed
Code:$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.
The JSession::getFormToken() just set a token to avoid security problems.
To get the user id you can use by example :
Code:
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.
10 years 1 month ago #3
by MusicInMe
Replied by MusicInMe on topic Subscribe button on front page
Wasn't easy but finaly got the solution:
Added code (just after
at the top of let say in template/my_template/html/category/default.php
and then, where the code must be shown
Added code (just after
Code:
defined ( '_JEXEC' ) or die ();
Code:
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
Code:
<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.
Time to create page: 0.295 seconds