Iron Router pathFor does not work when looking for route '/' or ''.
I'm trying to create a link to homepage here but it does not seem to accept that route. Routing is set properly and works properly by entering it.
Is there a special pathFor for homepages?
You should pass the name of the route as the parameter. Take a look at here
if #user3594721 make spacebars
{{pathFor "/"}}
it is wrong, and check inside Router method. also you don't have route for homepage (or root page), make route for homepage
change
{{pathFor "/"}}
to
{{pathFor "something you typed name of homepage"}}
Related
For a project I am making I will be using a route that looks something like this: collection/id. The server returns an 404 error when the given ID does not exist.
When this happens I would like to push the 404 error page that I have in my router.
{
name: 'notfound',
path: '/:pathMatch(.*)*',
component: () => import('../views/PageNotFoundView.vue'),
}
Now this is achieved by calling the following code: this.$router.push('/notfound');. However, this also changes the URL in the browser which is not something I would want. When reloading the page you should be going to collection/id.
Is there any way to push a navigation route (or component?) without changing the URL displayed?
Example: https://google.com/ajdfkasf doesn't go to https://google.com/404 but rather you keep the link and can refresh it. I could include the component in the view instead of trying to solve this with routes, but that would add overhead to all kinds of views.
Refering to the SoanataORMAdmin's documentation, it is possible to change the default route of object links.
By default, it's the edit route. I don't want it at all and need to change it to show without override all my admin class.
What is the better way to override the default route ?
Thanks.
The best way is to override the twig by extending SonataORMAdminBundle.
To do this, you need to :
install SonataEasyGenerate Bundle
use the command php app/console sonata:easy-extends:generate SonataORMAdminBundle
this will generate a new repository Application/Sonata/DoctrineORMAdminBundle
Then you need to go to Application/Sonata/DoctrineORMAdminBundle/Ressources/views/CRUD and paste the twigs from the vendors (vendor/Sonata/DoctrineORMAdminBundle/Ressources/views/CRUD)
Finally, change the links in the twigs.
For example, if you want to call the list view to call the show route for a many to one relation :
edit list_orm_many_to_one.html.twig to call generateObjectUrl('show',...) instead of generateObjectUrl('edit',...)
Hope this will help.
How to make the URL of the page: one/two/three? This work must be done via a url variable in the template. I use metalsmith-permalinks plugin. I have it hooked up and the pattern is specified as :url.
Later in the template write the url: hello/world. But the web address of this page is converted into a hello-world.
How to make the page address, type hello/world ?
Option :url will replace all characters / on -. Probably the only way in this situation at the moment - create the directory hello/world, and add Metalsmith template file. I had a similar problem and solved it this way.
After a form is submitted and handled, I want it to redirect back to the page with the form on it, with a #anchor link, like this:
/facility/some-facility#form
How is this best achieved with Silverstripe?
return $this->redirect($this->Link .'#form')
sends the browser back to
/facility/some-facility/Form#form
and redirectBack() does not take any arguments
As pointed out by Colymba in the comments, the ->Link() is a method, not a property
return $this->redirect($this->Link() . '#facility-enquiry');
gives the correct redirect.
Obviously one option is
return $this->redirect($_SERVER["HTTP_REFERER"] . "#facility-enquiry");
But that seems a bit basic when all the other redirection functions offer a bit of error checking etc.
im have a page. The url page is:
mydomain/web/app_dev.php/Common/homePage
And i need create a link. The href of anchor must be link to
mydomain/web/app_dev.php/Menus/seleccionarMenu
The action of the second link, is in other controller, in other bundle.
How make this ?.
Any ideas ?
Use path():
Some Text
routeName follows basic Symfony naming conventions, or explicit name if given in route annotation.