ZF2 view script path generation - zend-framework2

The ZF2 tutorial puts the view scripts into module/Album/view/album/album and it says "stored in our module’s views directory within a directory named after the controller".
The controller is AlbumController so that must be one of the 'album'-s. But where does the other 'album' come from?
I have tried to debug the framework to figure this out, but with all this magic calls and triggered events I got lost completely in a minute.

The default structure is:
view/[module]/[controller]/[action].phtml
As you have an Album Module, and an Album Controller, your views would go into that directory.
if you have an action named indexAction then your view would be called index.phtml

Related

How can I reference a script that is in my pages directory?

I'm trying to keep a good practice of keeping context together and in that regard, I like how Razor Pages forces you to place your view models next to its view. I'd like to do this with script files as well.
For example, if script is a bit large and is only used on this particular page, it may not be the cleanest thing to have it in a render section in the cshtml. Instead, I'd want to place it into its own .js file. But to keep the project easy to navigate for team members, I'd like to place that .js file in the same folder next to its view and view model. I'm not sure how to link that file, or if I even can. If I give src a path to the file, it is not found. Assuming that's because wwwroot is the only folder setup to host static files.
Suggestions?
You can add an option to the StaticFilesProvider in your Configure method:
app.UseStaticFiles(new StaticFileOptions()
{
FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(),"Pages")), RequestPath="/Pages"
});
See the documentation on Static Files in ASP.NET Core: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/static-files?view=aspnetcore-2.1

How to acess AreasController that is in controller folder that is outside of .Net's Areas Folder

I have a Controller called AreasController, I added Areas folder to the project so I can create some Areas, by doing this I noticed that the url: /Areas is pointing to Areas folder not to my AreasController.
Is there a way to solve this, or I'll have to rename AreasController.
You can specify the associated route to that controller by adding an annotation on the top of the class name
as here:
[Route("Areas")]
for more reading please check Microsoft docs

Cannot find my View

All my Views are defined in a folder called "site_admin". But when I browse like this http://localhost:1234/site_admin/home/index. It gives me the following error
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /site_admin/home/index
It looks like its having problem finding the location of my View. All my views should be inside the "site_admin" folder and should be accessible from there.
Any help would be greatly appreciated.
Here is how routing works in MVC. Default routing means you have a controller, like UserController and in that file there is a method, say NewUser(...). Then you also need a view folder named User and inside that a NewUser.cshtml file. Now, if you to to mysite.com/User/NewUser that will first hit the User controller and look for the NewUser method. Once that code is run it will look for the NewUser.cshtml file in the Views/User folder.
There are several way of overriding this default routing (routeconfig.cs, route attributes, etc) but that is the basics of how it all ties together.

overriding front template translations doesn't work

I'm working on prestashop and I'm Trying to override "order detail page" in front (customer's details orders).
This is how I did :
I copied file \controllers\front\OrderDetailController.php into folder \override\controllers\front\OrderDetailController.php
I copied also default template file order-detail.tpl into folder override/customtemplate/order-detail.tpl
And In OrderDetailController.php I have specified template directory like that
$this->setTemplate(_PS_OVERRIDE_DIR_ . '/themes/parfum_evo/order-detail.tpl');
I tried, it works fine except translations. Even watching the documentation, no test solution seems to work.
Could anyone help me? Thank you in advance :'(
The php override sits in the correct place. As for the other, you specified the path the override/customtemplate/order-detail.tpl but then placed it in override/themes/parfum_evo/order-detail.tpl. I take it as customtemplate is farfum_evo really, but you need to add another one named themes, after override, using that structure. I think. Because there is a hook named
DisplayOverrideTemplate
Which should take care of this, while I believe setTemplate for controllers will always grab from the main theme folder

Getting 'Multiple Controllers Found' Error

I am getting this runtime error from a new project.
I actually don't have any duplicate controller names. They all reside in my Controller folder and have unique names. I am not sure why I'm getting this.
I also did follow the suggestion to add a namespaces parameter even if they were all located in one folder.
Multiple types were found that match the controller named 'Channel'.
This can happen if the route that services this request
('{controller}/{action}/{id}') does not specify namespaces to search
for a controller that matches the request.
If this is the case,
register this route by calling an overload of the 'MapRoute' method
that takes a 'namespaces' parameter.
The request for 'Channel' has
found the following matching controllers:
MyProject.Controllers.ChannelController
MyProject.Controllers.ChannelController
It turns out I had another DLL in the same folder. I renamed my project, and the older DLL was there with exactly the same controllers.

Resources