Symfony use_javascript() routing issue - symfony1

i am using symfony 1.4.11; use_helper('Url').
On using link_to('new',course/course/type/new),
the url it show is ../backend_dev/backend_dev/Course/course/type/new
instead of
../backend_dev/Course/course/type/new.
Same issue exist for form_tag also.
Edit
Above issue was solved.By setting no_script_name: true at config and clearing cache.
But image_tag(),use_stylesheet() and use_javascript() gives path as for example
use_javascript('jquery-1.6.1.min.js')
==>../web/backend_dev/js/jquery-1.6.1.min.js
instead of
use_javascript('jquery-1.6.1.min.js') ==>../web/js/jquery-1.6.1.min.js
Any help appreciated.

Hard to say without your full routing.yml but the one thing i see is that your internal_uri should be expressed as an abs url with a query string like:
link_to('new','/Course/course?type=new');
Note the forward slash at the beginning. Also the module name should be the real module name, not the routed one so if the maodule is /apps/backend/modules/Course then the module in the internal URI should be Course not course same with the action name.
If the route is named then you should use one of the following:
link_to('new','#routename?type=new');
OR
link_to('new','routename', array('type'=>'new'));

Related

Drupal internalURL rewrite

I am trying to do something very simple, but can't seem to find a way to do it. What I want is to have a URL in the form of /en/products/accessories+software internally route to /en/products?accessories+software.
/en/products is an existing page, whatever comes after are basically filters, which are appended to the URL so they can be linked directly. Now it works by appending it as query parameters, but using /filtersHere would be preferred. But this of course results in a 404 error.
Site is running D9.
Why not use Drupal's Routing system and make dynamic arguments on URL?
In the module.routing.yml, something like below should do:
module.mypath:
# Dynamic arguments enclosed in { }.
path: '/book/export/{type}/{node}'
defaults:
_controller: '\Drupal\module\Controller\MyController::index'
More details available in the official doc:
Drupal - Structure of routes

#Url.Action("Action", "Controller") returns "/cgi-bin?action=Action&controller=Controller"

For some reason it thinks the target is an Apache server - I suspect?
The MVC is V5.2.3 and its dependancies are correct as per nuget
. I have searched and searched to no avail.
EDIT
The code is simply #Url.Action("Action", "Controller")
So I created a brand new MVC project and using exactly the same code the correct code was returned.
http://localhost:53143/Controller/Action
EDIT 2
I removed my web.config files as the problem is not there.
I got in touch with an expert and he looked at the project and answered as below.
(BTW I have 'cgi-bin' in a route as there are old URLs out in the wild that relate to my domain previously being hosted on an Apache server and which I cannot change.)
The answer
I digged a little more into the source code of the mvc helpers and, yes, the two issues (I had a similar problem Html.BeginForm with overload causes form action to be '/cgi-bin?action=Index&controller=Home' and so the HomeController is bypassed) are related since Url.Action and Html.BeginForm boil down to calling one and the same method: UrlHelper.GetUrl... Now, what this method does is:
Retrieve the current URL including controller, action, area...
Add or replace the parameter(s) you specify,
Find the best matching route! <==
If there are any route variables - push the provided parameters into those variables.
Stick the rest of the parameters into the query string <==
I have deliberately highlighted point 3 & 5, with point 3 being the most important. So, UrlHelper.GetUrl (and Url.Action and Html.BeginForm respectively) needs a route and it searches through the available ones to find the first match.
Now, here comes the problem with your mixed webforms-mvc app - an issue which is not present when you are dealing purely with MVC: You are using MapPageRoute!!! Please, note that it is different from MapRoute. And MapPageRoute uses the PageRouteHandler class to create the route whereas MapRoute uses the MvcRouteHandler class and it makes all the difference because PageRouteHandler creates the route in such a way that it's always a good match for UrlHelper.GetUrl("ActionName", "ControllerName") with the action name and controller name being thrown into the query string as parameters (point 5).
So, what happens with your set-up is that Url.Action is searching for a route and is hitting the first one created by MapPageRoute and in your case this is:
routes.MapPageRoute("cgi-bin", "cgi-bin/{*theRestcgi-bin}", "~/home/Search.aspx");
That's where that arcane cgi-bin part of the query string comes from, giving the impression that the framework is actually searching for some virtual/physical folder.
As for the proper solution: either define a suitable route or specify the url as a simple string the way you have done. I think, your solution is the better one as you won't have to move around the route definitions in the RouteConfig class.

How to use external URL as path (Rails)

I am trying to create routes within an app that I am working on like the following example:
http://www.example.com/entrepreneur.com/article/251468
My hope is to basically load an external page into an iframe by adding our domain to the URL. It needs to be without storing the external url in a database because I need every website accessable in this way. How can I do this?
You need a route with a wildcard like this:
get 'url/*args', to: 'your_controller#your_action'
See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments
I would suggest you namespace the route under some keyword to catch this wildcard route explicitly (hence url in the above).
You may need to tweak the route to allow periods to prevent them from becoming the format. I forget if that's true for these or not.

FormIt - redirect hook issue

ISSUE: I'm using FormIt and the redirect hook is not working for me.
It is redirecting to http://www.example.comPageName.html instead of http://www.example.com/PageName.html. It is not placing the forward slash after the page name.
Has anyone seen this issue before?
Here is my FormIt snippet.
[[!FormIt? &hooks=`email,redirect` &emailTpl=`MyEmailChunk` &emailTo=`mypersonalemail#email.com` &emailSubject=`Contact Us form submission` &redirectTo=`35` &emailFrom=`info#domainnamme.com`]]
Yes, the MyEmailChunk exists.
The email addresses are dummy values
The resource with id 35 is in the same context and is published and is hidden from the menus.
I'm using friendly urls.
If I try another resource it works.
URL generated in the following code
$url = $this->modx->makeUrl($this->formit->config['redirectTo'],$contextKey,$redirectParams,'full');
'full' means URL is absolute, prepended with site_url from config ( http://rtfm.modx.com/display/revolution20/modX.makeUrl ). Please check your site_url variable in /core/config/config.inc.php
Actually the site_url variable needs to be checked in the System Settings.
Make sure you have a trailing slash.

how to remove sitecore folder name in the url?

I created a sitecore year/month/day folder structure in the content tree, when i view each article under the folder node, the url could be http://local/landing/year/month/day/article1.aspx, how could I make the url like this: http://local/landing/article1.aspx?
just remove the year/month/day structure in the url.
Is there some function in sitecore like remove or hide special templates in the frontend url ?
Any help , Thanks .
You can do it in 2 ways:
Use IIS 7 Url rewrite module to change the url. This way the url will be rewritten before it gets to sitecore and you don't need to change any code. You can find more info at the iis website
You can create a custom Item resolver and add it to the RequestBegin sitecore pipeline. Alex Shyba wrote about it here.
It sounds like you may have thousands of these items, but even so, you may want to use the built in functionality of Sitecore and consider creating aliases for each of these items. Programmatically creating an the alias on an ItemSaved event or ItemCreated is probably easiest.
As #marto and #seth have said, you can use URL rewriting or aliases to solve this.
There is, however, a drawback to doing this, irrespective of how you choose to do it.
If you have very many items (your structure makes it sound like you may do) then either method will require that the URL is unique. Removing the date structure from the URL means that all items in your landing section will require unique URLs (whether inherited from their item names or by some other means). This can impact on SEO for your site, as authors may have difficulty finding an unused name that is also human readable and good for SEO. It's unlikely you want to use ugly GUIDs in your URLs.
2 options
Change Bucket configuration and the set the required folder structure, bucket configuration can be found in Sitecore.Buckets.config file
Extend GetFromRouteValue Item Resolver and overwrite the ResolveItem() method to get the bucket item.
The default GetFromRouteValue class reference can be found in Sitecore.MVC.config file and replace this with your own customized implementation.
We have implemented with customized routing and getting the exact item if the route path matches.
Thanks,
Jisha

Resources