Customize Drupal URL by content type - url

I have set up a content type - cars. Is there a way to automatically add the prefix /cars/ before the id? So for example domain.com/cars/2. I may also have more content types which I need to do this for. Standard pages however need no prefix.
How can I change the URL format based on the content type?

The Pathauto module was built for exactly that:
The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias.

Use the pathauto module with token [content-type]/[node]

Related

Using Adwords, is it possible to create url specific to each keyword for thousands of keywords?

Every URL ends with the same pattern, "Part-123456789" where the "Part" is a constant and the "123456789" is a part number. I want to run an adwords campaign targetting every part # and directing to the unique url for that part. Is there a simple way to do this?
Note: Adwords Editor is giving me ambiguous rowtype errors whenever I try to upload the keywords and URL's together in the same line of a .csv file.
The available value track parameters for AdWords tracking templates offers both the keyword ID and matched keyword:
https://support.google.com/adwords/answer/6305348?co=ADWORDS.IsAWNCustomer%3Dfalse&hl=en
You could use this to determine the part number in the URL but it may require some mapping in the content management system.

Using optional parameters in Umbraco 7 Urls

Am new to using Umbraco. I need to create Urls with an an optional parameter on the end e.g.
mysite.com/people/john
mysite.com/people/jane
etc
however by default Umbraco appears to require a separate page for each person. Is there a built method in Umbraco that will allow me to define the last part of the Url as an optional parameter or do I have to write a custom route for it?
Thanks
You have a couple of options here.
Use IIS URL Rewriting to rewrite your URLs under the hood and rewrite /people/john to /people/?person=john say. Then you can pick up the person from the query string on the page.
Write a custom URL Finder that looks for the URLs and does some stuff under the hood, like get the people page, and then set a context item with the person name in for you to use in your views etc.
You could write a custom route for it. Custom routing in Umbraco is slightly different to in normal MVC. Here is a blog post detailing how you can do it: http://shazwazza.com/post/custom-mvc-routes-within-the-umbraco-pipeline/

Symfony2 url hierarchical structure

I was wondering whats the best approach to have a hierarchical structured urls such as for example:
If i have 3 categories
-Cateogory1
--Category2
---Category3
I would like the urls to resolve to
/category1
/category1/category2
/category1/category2/category3
I am also using jms_i18n_routes to support locales in the routes. I have the SymfonyExtraBundle already enabled. The only way i see for now is just to create a new router and add it to the list of routers but the problem is the jms_i18_router extends the symfony default router so if i do that i will be able to have internationalized urls for all the default routes but not for this custom router, which means i will have to copy the functionality which i already have into the new router (pretty pointless)
Furthermore if I add this router for a category hierarchy, I will probably have to have different versions of it for different entity types in addition to categories where i want this functionality (or have one giant if statement to check for each scenario) - neither solution seems very elegant to me, so I was wondering what are your thoughts on the matter?
Thanks!
you can do this by setting rout repetitive pattern, use regular expression on the "requirements" part of rout, similar this:
# categories rout:
categories:
pattern: /{cat}
defaults: { _controller: HelloBundle:Default:categories }
requirements:
cat: (category[1-9]\/)+
notice:
you should recognize slashes on $cat variable on the "categoriesAction" function.
of course if you want make dynamic hierarchical URL from non-ascii characters and make this URL from persisted entities i think you can do this by create URL from a ascii entity field such as entity-id or other entity-special-keys.

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

How does magento parse url?

We used django and in django there is one file urls.py which mention all possible url patterns. So we just want to know that when i open url http://localhost/magento/index.php/test123.html how this will map to product and which file i can check for this.
Magento has more than one way of matching URLs. modules can register their own patterns, and these will generally be of the form /module/controller/action
In addition, CMS pages have URL identifiers and these can be anything you like - they can contain /s to give the illusion of hierarchy, but they're not significant.
Finally, Categories and Products have URL identifiers and there's a whole table of URL rewrites that map a path (/[category]/[subcategory]/[product] for example) to a product. In your example, I would guess that the product's URL identifier is 'test123' and that the store is setup to suffix URLs with '.html'
So, there's no file to look in (in this case), but rather the database/admin area.

Resources