Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID Sign In with Twitter
Support for Vanilla Forums Cloud product

In this Discussion

Follow Us


adding additional links along side tabs above content

edited November 2011 in Questions
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

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

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.

    My addons: NillaBlog | Vanoogle

  • 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.

    422 Real Estate Australia , now open Check it out

  • 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

    422 Real Estate Australia , now open Check it out

  • 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?

    My addons: NillaBlog | Vanoogle

  • 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

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • 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.

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • 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.

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • 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

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • 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>';
    }

    }
    }

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • 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?

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    try class custom2ThemeHooks implements Gdn_IPlugin {

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

  • tried it with the code update insterting
    class custom2ThemeHooks implements Gdn_IPlugin {
    again nothing happens on the page.
    I have the file called class.custom2themehooks.php and its in my theme's (titled custom2) main folder.
  • there is another theme hook in the folder, is that a problem? This theme hook is called class.embedfriendlythemehooks.php
    If I remove it and keep in my custom theme hook it prints the customtheme hook code at the top of the page. If I remove class.embedfriendlythemehooks.php and my customethemehook the page displays correctly. I'm not sure what the class.embedfriendlythemehooks.php does...
  • awesome, worked perfectly, thank you so much
  • sahotataransahotataran Developer, Bay Area - CA ✭✭✭
    you r welcome :)

    Theme Charcha for great desktop and mobile experience! - drop me a message :)

Sign In or Register to comment.