From: Demian K. <dem...@vi...> - 2013-08-27 17:49:56
|
When you call new \VuFindLocal\View\Helper\phoenix\ConditionalLinks($hp); you are passing the $hp value to the ConditionalLinks' __construct() function... you should then save that value for future use. Using $hp later in a view template won't mean anything to PHP, since the $hp variable only exists within the scope of your factory function. So you might have, within ConditionalLinks, something like this: public function __construct($hp) { $this->hp = $hp; } public function getHP() { return $this->hp; } and then you could use: $this->ConditionalLinks()->recallLinks($this->ConditionalLinks()->getHP()); ...or you could modify the recallLinks function to use $this->hp internally so the value doesn't need to be passed in from outside. Does that make sense? - Demian From: Brad Busenius [mailto:bbu...@uc...] Sent: Tuesday, August 27, 2013 1:44 PM To: vuf...@li... Subject: Re: [VuFind-Tech] ini config values in custom view helper I should also add, the variable is returning the config value correctly from theme.config.php, but from within the view helper it returns null. I'm definitely failing at passing it. On 8/27/13 12:38 PM, Brad Busenius wrote: Fantastic, I'm on the right path! I'm doing something very similar in the theme.config.php: 'ConditionalLinks' => function ($sm) { $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); $hp = !isset($config->Site->url) ? false : $config->Site->url; return new \VuFindLocal\View\Helper\phoenix\ConditionalLinks($hp); }, The only thing I can see that might be different is that I'm trying to pass it to a specific function in the call to the view helper: $this->ConditionalLinks()->recallLink($hp); I've also tried: $this->ConditionalLinks($hp)->recallLink(); and $this->ConditionalLinks($hp)->recallLink($hp); in my troubleshooting. On 8/27/13 12:31 PM, Demian Katz wrote: If you use a factory to construct your view helper in your theme's theme.config.php file, it shouldn't be too hard to push in configuration values... there are several existing view helpers that do this. For example (from the root theme): 'addthis' => function ($sm) { $config = $sm->getServiceLocator()->get('VuFind\Config')->get('config'); return new \VuFind\View\Helper\Root\AddThis( isset($config->AddThis->key) ? $config->AddThis->key : false ); }, This pulls the [AddThis] / key value from config.ini and pushes it into the AddThis helper. Feel free to share code if you have something similar but it isn't working for you -- maybe it's just a slightly misaligned configuration array or something similar. - Demian -----Original Message----- From: Brad Busenius [mailto:bbu...@uc...] Sent: Tuesday, August 27, 2013 1:13 PM To: vuf...@li...<mailto:vuf...@li...> Subject: [VuFind-Tech] ini config values in custom view helper I'm having a terrible time trying to pass config values from the .ini files into a custom view helper in my custom theme. Is this a non-standard practice? What's the best way to go about this? As always, your help is greatly appreciated. Brad Busenius ------------------------------------------------------------------------------ Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk _______________________________________________ Vufind-tech mailing list Vuf...@li...<mailto:Vuf...@li...> https://lists.sourceforge.net/lists/listinfo/vufind-tech ------------------------------------------------------------------------------ Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more! Discover the easy way to master current and previous Microsoft technologies and advance your career. Get an incredible 1,500+ hours of step-by-step tutorial videos with LearnDevNow. Subscribe today and save! http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk _______________________________________________ Vufind-tech mailing list Vuf...@li...<mailto:Vuf...@li...> https://lists.sourceforge.net/lists/listinfo/vufind-tech |