Custom Smarty Functions for changing breadcrumbs not working

Hi guys,

I'm new to Vanilla. I'm trying to modify the breadcrumbs and found this post:


Somehow this is not working for me. Either this is not the right way in 3.3 any longer or I did something wrong.

The file class.embedfriendlythemehooks.php in the folder /srv/forum/forum/root/themes/EmbedFriendly looks like this:

<?php defined('APPLICATION') or die();

/**
 * Sample implementation of a theme hooks class to show
 * the use of custom Smarty plugins.
 */
class EmbedFriendlyThemeHooks implements Gdn_IPlugin {
    /**
     * Setup function is needed for this class, so don't delete it!
     *
     * @return bool Dummy return value.
     */
    public function setup() {
        return true;
    }


    /**
     * This function hooks the Smarty init to add our directory
     * containing our custom Smarty functions
     *
     * @param object $sender Smarty object.
     * @return void
     */
    public function gdn_smarty_init_handler($sender) {
        // add directory "/themes/MyTheme/SmartyPlugins/"
        $sender->plugins_dir[] = dirname(__FILE__).DS.'SmartyPlugins';
    }


    // whatever...
}


And the file function.custombreadcrumbs.php in the folder /srv/forum/forum/root/themes/EmbedFriendly/SmartyPlugins looks like this:

<?php if (!defined('APPLICATION')) exit();
/**
 * Render a breadcrumb trail for the user based on the page they are on, keeping in mind the level of Vanilla as a whole.
 */
function smarty_function_custombreadcrumbs($Params, &$Smarty) {
  $Breadcrumbs = $Smarty->Controller->Data('Breadcrumbs');
  if (!is_array($Breadcrumbs)) {
    $Breadcrumbs = array();
  }


  // Add the forums link to the crumbs
  array_unshift($Breadcrumbs, array('Name' => T('Forums'), 'Url' => '/'));


  // Add the home page link to the crumbs
  array_unshift($Breadcrumbs, array('Name' => T('Home'), 'Url' => 'http://www.example.com/'));


  return Gdn_Theme::Breadcrumbs($Breadcrumbs, FALSE);
}


Using the {custombreadcrumbs} in the default.master.tpl results in an error.

Does this method not work in the current version or did I name files wrong?

Thanks so much for any input.

Sascha

Sign In or Register to comment.