function render(Am_View $view) { if ($this->path) { $view->block = $this; // add plugin folder to search path for blocks $paths = $view->getScriptPaths(); $newPaths = null; if ($this->plugin && !$this->plugin instanceof Am_Module && ($dir = $this->plugin->getDir())) { $newPaths = $paths; // we insert it to second postion, as first will be theme // lets keep there some place for redefenition array_splice($newPaths, 1, 0, array($dir)); $view->setScriptPath(array_reverse($newPaths)); } $pluginSaved = !empty($view->plugin) ? $view->plugin : null; if ($this->plugin) { $view->plugin = $this->plugin; } $out = $view->render("blocks/" . $this->path); $view->plugin = $pluginSaved; // remove plugin folder from view search path if (!empty($newPaths)) { $view->setScriptPath(array_reverse($paths)); } return $out; } elseif ($this->callback) { return call_user_func($this->callback, $view, $this); } else { throw new Am_Exception_InternalError("Unknown block path format"); } }