Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
adding additional links along side tabs above content
jstnhickey
New
I'm not sure how to explain this really, but I just installed a board and would like to add some additional links to categories about the listing of threads.
I have my board set up like this.
http://imageshack.us/photo/my-images/543/screenor.png/
I would like to add links/tabs/buttons to my 3-4 categories next to "All Discussions" and "My discussions".
Any ideas how I can do this. I'm not great with coding, but can figure it out with guidance. I couldn't find any info in the documentation about editing these buttons/tabs.
I have my board set up like this.
http://imageshack.us/photo/my-images/543/screenor.png/
I would like to add links/tabs/buttons to my 3-4 categories next to "All Discussions" and "My discussions".
Any ideas how I can do this. I'm not great with coding, but can figure it out with guidance. I couldn't find any info in the documentation about editing these buttons/tabs.
Tagged:
0
Best Answer
-
sahotataran ✭✭✭i think you can only have one themehooks in one folder.
paste the code i gave you into the other theme hook and keep only on themehook in your theme folder.
also make sure you donot declare your hookpublic function DiscussionsController_AfterDiscussionTabs_Handler($Sender)
twice in your themehooks.phpThere was an error rendering this rich post.
0
Answers
There was an error rendering this rich post.
There was an error rendering this rich post.
http://formutantsonly.com/screen.png
Here's what I want
http://formutantsonly.com/screen2.png
I'd like to link my categories in those spots. I only have 4 categories and I like that the page shows them all at once, but if someone would like to sort them I would like that option too.
There was an error rendering this rich post.
There was an error rendering this rich post.
i use Vanilla 2.0.18.1 and here is what i will do:
i will create a theme hook public function
public function DiscussionsController_AfterDiscussionTabs_Handler($Sender){
$CategoryModel = new CategoryModel();
$_CategoryData = $CategoryModel->GetFull();
foreach ($_CategoryData->Result() as $Category) {
// (will ignore root node)
if ($Category->Name <> 'Root') $CountDiscussions = $CountDiscussions + $Category->CountDiscussions;
}
// Fetch every single Category...
foreach ($_CategoryData->Result() as $Category)
{
if ($Category->Name <> 'Root')
{
echo '< li >< a href="/categories/'.$Category->Name .'">'.$Category->Name.''.$Category->CountDiscussions.'</ a></ li>'; } } } there can be errors with opening and closing of some stuff meaning {} or ' ' or " " - but u can try this
There was an error rendering this rich post.
There was an error rendering this rich post.
There was an error rendering this rich post.
http://vanillaforums.org/docs/theme-hooks
I entered this code into a file called class.customthemehooks.php
class customThemeHooks implements Gdn_IPlugin { public function DiscussionsController_AfterDiscussionTabs_Handler($Sender){ $CategoryModel = new CategoryModel(); $_CategoryData = $CategoryModel->GetFull(); foreach ($_CategoryData->Result() as $Category) { // (will ignore root node) if ($Category->Name <> 'Root') $CountDiscussions = $CountDiscussions + $Category->CountDiscussions; } // Fetch every single Category... foreach ($_CategoryData->Result() as $Category) { if ($Category->Name <> 'Root') { echo '< li >< a href="/categories/'.$Category->Name .'">'.$Category->Name.''.$Category->CountDiscussions.'</ a></ li>'; } } } }
all I get is the code printed on the top of the page.
<?php if (!defined('APPLICATION')) exit();
to the begining (like I saw in other theme hooks) I get this error Line 19 is a
}
If I remove that I get this error
There was an error rendering this rich post.
public function DiscussionsController_AfterDiscussionTabs_Handler($Sender){ $CategoryModel = new CategoryModel(); $_CategoryData = $CategoryModel->GetFull(); foreach ($_CategoryData->Result() as $Category) { // (will ignore root node) if ($Category->Name <> 'Root') $CountDiscussions = $CountDiscussions + $Category->CountDiscussions; if ($Category->Name <> 'Root') { echo '<li><a class="TabLink" href="/categories/'.$Category->Name .'">'.$Category->Name.' '.$Category->CountDiscussions.'</a></li>'; } } }
There was an error rendering this rich post.
class custom2ThemeHooks implements Gdn_Plugin Gdn_Plugin { public function DiscussionsController_AfterDiscussionTabs_Handler($Sender){ $CategoryModel = new CategoryModel(); $_CategoryData = $CategoryModel->GetFull(); foreach ($_CategoryData->Result() as $Category) { // (will ignore root node) if ($Category->Name <> 'Root') $CountDiscussions = $CountDiscussions + $Category->CountDiscussions; if ($Category->Name <> 'Root') { echo '<li><a class="TabLink" href="/categories/'.$Category->Name .'">'.$Category->Name.' '.$Category->CountDiscussions.'</a></li>'; } } } }
Am I putting it in the wrong folder?
There was an error rendering this rich post.