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.
Related
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
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
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.
I have all my text inside view coding. I preffer to save it in app_resources, because i would to add other languages in future, and its look quite cleaner.
I just know that I need to use metatags in my view for text to connect it with file app_resource. How to it correctly, could you show me some examples how it looks like in view??
Thanks a lot and take care,
Ragims
You only need to create App_LocalResources folder in the same folder where you hold your views. Then give a name to zzz.resx. And then you can call resources in your view via zzz.
Example: *You have folder Contact in your View Folder.
Your add App_LocalResources to Contact folder. Then you give a name Contact.resx to your .resx file.
Finally in the view you can use <%= ContactResources.Contact.Index_ContactWithUs %> where Contact.Index_ContactWithUs - name of concrete resource.
Don't forget that in resources settings you can modify access type (Internal or Public).
I am using the help-balloons plugin
I would like to use it parametrized. I mean, the messages should come from a properties file. In the documentation appears the following:
<g:helpBalloon code="user.name" suffix=".help"/>
In this last example, the code attribute is used to look up the balloon's title within the message bundle and then the suffix is added to the code (producing user.name.help in our example) as the key to be used for looking up the content of the balloon.
My question is:
Where should be located this properties file (message bundle)?
Can I have one message bundle per controller?
Luis
if you looked at the source code for the help balloon tag, it literally uses the grails interationalization code to render the message if given a key. http://fisheye.codehaus.org/browse/grails-plugins/grails-help-balloons/trunk/grails-app/taglib/HelpBalloonTagLib.groovy?r=45243
check out this page http://www.grails.org/doc/1.0.x/guide/10.%20Internationalization.html it tells you where and how to name the file for message bundles.
as for a message bundle per controller, it doesnt seem like you can (at least not apparent from the documentation). but you can hack it by prefixing the message key by the controller name, and thus use the same message bundle file (message.properties_ but still be able to namespace each message.
Where are the Resource bundles:
There is a directory under grails-app called i18n where all the generated resource files are placed, start looking there and see how they are used in the app.
You may be able to just place multiple message files for your controllers in there for organization, just be careful of reusing keys as I'm not sure how that will be handled off hand.
How to access them:
Maybe this will help I hope:
http://www.nabble.com/Organizing-message-bundles-tt16169280.html#a16169280