I have a view with the node title as one of its fields. This title should link to another view page display and not to the node display. So I checked the output of this field to be a link and made the link path path-to-page/[title].
The problem is that this link shows up with the title in uppercase and when it contains more then one word the spaces between them show up. So instead of path-to-page/this-is-the-title the URL becomes path-to-page/This%20is%20the%20title. And I have the same problem with URL's coming from taxonomy term fields.
I have a feeling that this can easily be overcome with some PHP coding but since I'm a front-end guy I have no idea where to start.
Can anyone help me out here?
Comments
You are mixing the node url
You are mixing the node url and the node title. They are not the same!
Thanks for replying Joep. I
Thanks for replying Joep. I haven't been online for some days so sorry for the late reply.
I know the difference between node url and node title. The node URL is something like "contenttype/title".
But my problem is that I'm using a node title as a field in a View display that I need to point not to the node but to another URL like "not-the-contentype/this-is-the-title". In Views there is the option to output this field using replacement patterns, which in this case should be "not-the-content-type/[title]".
This results in "not-the-contentype/This%20is%20the%20title]" instead of "not-the-contentype/this-is-the-title", which is what I need.
We're talking Drupal so I'm sure there is a way to accomplish this, but I have no clue how.
www.opstijgendenevel.nl
I don't have drupal in front
I don't have drupal in front of me but I could have sworn when re-writing links in views there was an option to convert spaces to dashes.
_
yep-- there should be both a "case" option and "transform spaces to dashes in URL" option which would create the desired format.
I think I'm going crazy. I
I think I'm going crazy. I was looking through views last night and couldn't find these options.
You are not going nuts
You are not going nuts. I too remember seeing that "rewrite" function. But just to check your/my/our sanity, I pulled up a title View. Guess what? It does NOT provide for a way to rewrite the URL.
I know for a fact that this feature as described by worldfallz has appeared to me previously. Is it only available under certain circumstances. It sounds like the OP and I are both using Node:Title and not seeing the link re-writing function. Should something else be used?
Is it worth elevating this to the Views issue cue?
(I have a screenshot, but guess I can't upload it from here.)
A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com
Reading all these posts I
Reading all these posts I guess maybe I should post in the issue cue. At first I thought it was something I overlooked or could be themed in a way I was unaware of.
www.opstijgendenevel.nl
_
Are you guys looking at a node title "field" or a node title "argument" -- the url comes from an argument (not a field) and that's where those options are.
Bing! That's part of the answer
Okay WorldFallz, that is definitely where half the answer is. I guess that may be where I have seen the case conversion and hyphens for spaces substitution. But let me ask you this: If you have a View that includes a title, and you want to make that title link to a custom view that includes the title, body, and maybe other CCk fields, what are you using to create your link?
I can make my Views title link to catagory/place/[title] or catagory/place/[nid]. But then I end up with:
"catagory/place/this is the title"
or catagory/place/117. Neither of which is as SEO friendly or as clean as "catagory/place/this-is-the-title"
Maybe I only half-understand arguments. I thought it was for getting information FROM the URL line. Are you saying the Arguements section of Views can also be used to construct the URL? If so, can you point me to something that would educate me more?
Thanks!
A list of some of the Drupal sites I have designed and/or developed can be viewed at motioncity.com
_
You can create a view with an argument for title-- which will enable you to type the title into the address bar to navigate directly to the view you set up there. I had trouble understanding arguments at first too-- it's more difficult to explain than it is to use them.
Most of views2 documentation is in the advanced help, but some links that helped me grok it (i originally learned with views1):
I added the title as an
I added the title as an argument and changed the link to "not-the-content-type/"%1" But the output still has the spaces and capital letters, even with the option to convert spaces to dashes checked.
www.opstijgendenevel.nl
Here the same: how to convert spaces to hyphens for links??
For a tourist site we have got 95% of the basics working except..... spaces in the links to taxonomy...
Where mcfilms needs "catagory/place/this-is-the-title"
we need "tourism/monuments-and-buildings" but have space instead of hyphens.
Could this specific view be manually overriden, export the code and then tell this part:
'make_link' => 1,
'path' => '[name]/[name_1]',
that in 'path' the spaces should be substituted by hyphens?
Or could something like:
be applied somewhere? (or similar code, got it from somewhere, is not mine..)
I started with Drupal in 2007 and then my life got stuck...
I might be able to help clear this up.
McFilms/Hueij:
I think the way to accomplish this is to use the Views themeing layer to rewrite the node title (or whatever field you're using) with dashes and no spaces. You'd do this at the field level. You can place PHP inside a views template in your theme folder and use regular expressions to accomplish your rewrite.
WorldFallz advice and links are spot on and useful. However, it seems to me that what people are looking for in this thread is how to set up views to *output* URLs with dashes and no spaces. Getting views to accept these as arguments is a solved problem. Example: A view whose output is a list of links; these links are paths that trigger another view that accepts part of the path as an argument. The key problem is how to get the initial view to output the nicer (spaceless) links that then can be used to jump to a more specific view that accepts the URL arguments.
I don't know how to do this except via Views themeing...
Use redirects
Hi after about a year of using a static list to the most importante tourism categories, yesterday I tried and discovered that the question can be solved by just adding redirects for the terms with spaces in the name. Maybe not very elegant, but it works. If you don't have too many terms with spaces in them works just fine!
so for example we now redirect "Monumentos y edificios" to "monumentos-y-edificios"
as simple as that.
I started with Drupal in 2007 and then my life got stuck...