it's probably obvious because i didn't find anyone who talk's about it:
there is module/controller/action - but what if the website depth is much deeper
?
for example:
module/controller/action/sub-page(s)/sub-sub-page(s)/and so on..
is routes is the correct way for it?:
puting the action for the module/controller/action/sub-page in the controller and making a route for it.
Am i missing something or this is the way to do it?
The Sub-page is a actually not a Sub-page but still rendered by an view script that refers to an controller/action.
Your logic would mean that after the view script is again a controller/action but this is not correct and would violate MVC structure.
Read Zend Framework & MVC Introduction.
Related
I am currently in the process of building an application with ZF2, everything is going well so far, but I am just having trouble with the page titles (as in the <title> tag in the <head>).
In my layout.phtml I have it statically set a string using $this->headTitle().
I want it to basically include the name of the module, controller and action by default, just like the doc page suggests:
http://framework.zend.com/manual/2.1/en/modules/zend.view.helpers.head-title.html
However when I try and implement the example code, I get an Exception.
Frankly the documentation should at least show you the best place to put this code.
I am looking for an example that a ZF2 noob can follow. I basically want to place some code somewhere (presumably Application\Module.php) so that I can set the default title as "Module - Controller - Action", then I need an example of how to override it easily from each controller or view (whichever is preferred)... please help! :)
As per Sams comment...
Readthedocs has the working example: http://zf2.readthedocs.org/en/latest/modules/zend.view.helpers.html#headtitle-helper
Thanks for your help Sam!
I am still very new to Zend Framework and work on my first small Project. I have now come across from Routing, which is a great tool. Unfortunately I do not get it to run on my Ajax Link. I also can't find any information about it. Is there a way to add routes to an Ajax Link? Thank you very much in advance for any hint. Below is my try, but no sucess.
echo $this->ajaxLink("Remove",array('article' =>$this->escape($entry->id),'deleteB',true),
your ajax link should point just as normal link to the action in your controller. The only thing you need to do is disable rendering view which is by adding:
// path/ExampleController.php
public function removeAction()
{
// Disable layout
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
// Your code to remove goes below
}
In my opinion ajax does not need special route. Hope that helps somehow
In the docs there doesn't seem to be any info on passing a route name as a parameter, at least I cannot find any - I'd be happy to be proven wrong.
I guess you can work around this problem for now, constructing the $url with the url() view helper and passing it then to the ajaxLink helper. Check out the ZF documentation page to make sure you pass the right parameters in the right places.
I'm building a .NET MVC application. This is mobile web and i cannot use jQuery.
In my application every process is a 3 step action witch leads me to a 3 aspx per process.
My processes can be categorized so i'd like to code my controllers like: ProcessTypeAController, ProcessTypeBController.
My Views should be like: \ProcessTypeA\Process1\1.aspx, \Views\ProcessTypeA\Process1\2.aspx and \Views\ProcessTypeA\Process1\3.aspx.
By convention this not work because the Controllers dont have the same "location" than Views.
Please Help in this question!
Thank U ALL.
You could specify the location of a view:
return View("~/Views/ProcessTypeA/Process1/1.aspx");
As an alternative you could write a custom view engine in order to modify the default view location conventions. Scott Hanselman wrote an excellent blog post about how this could be achieved.
Is there any way to alter the behavior of Url.Content rendering mechanism so that my static content in the page is loaded from an external server?
To explain further, suppose you have an ASP.NET MVC 2 website, http://www.example.com and at some point, your want your static content to be loaded from static.example.com . But you have coded your application with syntax like Url.Content("~/Content/images/a.gif"). From that point, is there some configuration change within the ASP.NET MVC to render these URL's as "http://static.example.com/Content/images/a.gif"?
Thanks in advance.
Unforunately there is no such configuration setting. Your best approach would be to write your own helper extension method hanging off of UrlHelper that you control.
I'm new to Zend Framework.
I have a menu of tabs that is used on various views but I need to highlight which section the user is in.
I have seen placeholders but they don't seem very flexible and don't really do the job since I can't access any variables to see what area the user is in.
Normally I would do this as an include, but not sure where to go with Zend.
Thank you for any help.
Zend_Navigation takes care of all your navigation problems:
Zend Framework: Documentation: Zend_Navigation - Zend Framework Manual