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

edited November 2011 in Vanilla 2.0 - 2.8
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.
Tagged:

Best Answer

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    Answer ✓
    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 hook
    public function DiscussionsController_AfterDiscussionTabs_Handler($Sender)
    twice in your themehooks.php

    There was an error rendering this rich post.

«1

Answers

  • Do you think you could mock up in a drawing what you want so we can get an idea of what they are for and how you want them to look? Otherwise, not really sure what you mean.

    There was an error rendering this rich post.

  • 422422 Developer MVP
    That image link throws up lots of popups , so couldn't see larger image. Are you using embedded forum, have you got link o the site.

    There was an error rendering this rich post.

  • site is private sorry. Here's what I have
    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.
  • 422422 Developer MVP
    edited November 2011
    Sorry cannot help, without link. Best of luck tho,there are some clever guys here

    There was an error rendering this rich post.

  • I am using the embedded theme, with only some changes to some colors. fyi
  • Not sure how to add tabs there in the embedded theme... @Lincoln, any pointers?

    There was an error rendering this rich post.

  • any ideas out there?
  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    edited November 2011
    seems like you want your categories to display next to the all discussions.
    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.

  • little lost... can you explain what this file should be called, where it should go, etc?
  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    did you go through the documentation for vanilla? i suggest you to go through that first. this is a hook that will go into your theme hooks and it will do its job - as you wanted.

    There was an error rendering this rich post.

  • hmm i'm reading the documentation, but hot having luck creating a theme hook plugin. I guess i'll do some more research
  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    yup. you can create a themehooks in theme folder and use the above code there or you can use it any enabled plugin and hook the code in there.

    There was an error rendering this rich post.

  • this documentation is telling me that it goes in the plugin folder? This is what I tried, is this not the correct documentation.
    http://vanillaforums.org/docs/theme-hooks
  • edited November 2011
    Ok so my theme is called custom
    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.
  • If I add this code
    <?php if (!defined('APPLICATION')) exit();
    to the begining (like I saw in other theme hooks) I get this error
    Fatal error: Class customThemeHooks contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Gdn_IPlugin::Setup) in /home1/formutan/public_html/bsb2/themes/custom2/class.customthemehooks.php on line 19
    Line 19 is a }
    If I remove that I get this error
    Parse error: syntax error, unexpected $end, expecting T_FUNCTION in /home1/formutan/public_html/bsb2/themes/custom2/class.customthemehooks.php on line 19
  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    hi @jstnhickey - will work on the code an post the whole code here till monday/tuesday. thanks

    There was an error rendering this rich post.

  • thanks a ton
  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    edited November 2011
    ok so here is the hook @jstnhickey which works for me
    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.

  • I have tried to put this code into a file called class.custom2themehooks.php into the theme folder but nothing is happening when I load up the page. I inserted this code
    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?
  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    why do you have Gdn_Plugin twice?

    There was an error rendering this rich post.

Sign In or Register to comment.