What do i need to set in order to not route urls like :component
:method but :module :component :method ?
The default route is set with run('../application/controllers');
so i thought to replace this with:
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory(array(
'default' => '../application/modules/default',
'projects' =>
'../application/modules/projects/controllers',
'shop' =>
'../application/modules/projects/controllers'));
to set the default path for the viewRenderer i also add:
$viewRenderer =
Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setViewBasePathSpec('../application/views');
so i have application/views/shop for shop templates and
application/view/admin for admin templates.
But how to tell the default router to use :module :controller
:component :parameter
so i have urls like domain.tld/shop/list/by-data or
domain.tld/admin/user/login ?
I allways get "Invalid Controller (index)" if i specify an module name
in the url, when i enter something else for module (something not
defined with setControllerDirecoty) i get
"Invalid Controller (notamodule)".
What am i doing wrong ?
Matthew Weier O'Phinney wrote:
-- Truppe Steven <[EMAIL PROTECTED]> wrote
(on Thursday, 23 August 2007, 09:13 PM +0200):
I can't tell you how happy i am about this few lines of code =)
Thank you very much!!
My pleasure! I foresaw exactly this sort of situation when I was
developing the ViewRenderer originally -- in part because I was already
working on a project that would need to do so. :-)
I must say that the zend framework is far the best web framework i've
seen. It takes havy load of the programmer and so makes it easy to write
full featured web applications in short time.
I'm glad it's fitting your needs!
You work at Zend or as a freelancer ?
Full-time employee. I've been with Zend for almost 2 years now, and am
transitioning from our online operations team to working full time on
the framework team.
Matthew Weier O'Phinney wrote:
-- steven truppe <[EMAIL PROTECTED]> wrote
(on Thursday, 23 August 2007, 08:30 PM +0200):
My main understanding problem is how to make ViewRenderer use the
Smarty_View instead of Zend_View, so i can work with the ViewRenderer.
or should i turn the ViewRenderer off and make my own
Zend_Controller_Action_Helper that creates the smarty view instanzes for
the controllers ?
the first method would be the best practice i think...
hope someone can help a beginner with a few understanding problems.. it
needs a bit time to realise all core components of the framework.
No problem -- that's part of my job!
You can actually get the ViewRenderer to use your custom view class
easily. Do the following in your bootstrap:
$view = new Smarty_View();
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->setView($view);
and that's all there is to it; when the ViewRenderer is invoked in
controllers, it will use the view object you've provided.
On Thu, 23 Aug 2007 20:08:12 +0200, Matthew Weier O'Phinney
<[EMAIL PROTECTED]> wrote:
-- steven truppe <[EMAIL PROTECTED]> wrote
(on Thursday, 23 August 2007, 07:40 PM +0200):
i'm new to the zend framework and try to get the smarty wrapper from the
documentation work with the ViewRenderer helper that is used per
default.
I want the same behavious for dispatching and finding view scripts, i
just
want to render with Smarty_View instead of Zend_View so i don't have to
create the view each time in the controller.
I'm doing this now for a project. The main thing is that your Zend_View
Smarty wrapper needs to provide the full path to the file -- smarty
likes all templates to be in the same tree, instead of scattered across
multiple trees, but allows you to get around this with full paths.
Later it may be interesting to change the dispatch process to limit the
possible urls to only valid ones, this should be done in the bootstrap
file in general.. or am i wrong ?
That's what the ErrorHandler plugin is for -- it's basically a 404
handler (controller or action does not exist => forwards to error
handler).
|