Pete Posted August 28, 2011 Share Posted August 28, 2011 This one's for ryan, but obviously open for discussion to all. Whilst porting a reasonably large site over to PW I noticed that the ampersand character (&) gets stripped out when a URL is automatically created from a page title. Is there any chance this could be automatically converted to the word "and" instead? Sure it's not amazingly important, but it allows for more legible URLs. Link to comment Share on other sites More sharing options...
apeisa Posted August 28, 2011 Share Posted August 28, 2011 Not automatic translation, since that would ruin other than English urls. Can't you replace those before import or saving page? EDIT: Not sure what method you are using for import, but if you do it with API, you can set name different from title (you probably already knew this). <?php $p->title = "Cool & Nice"; $p->name = "cool-and-nice"; Link to comment Share on other sites More sharing options...
Pete Posted August 28, 2011 Author Share Posted August 28, 2011 I'm just creating the pages manually. Perhaps if it's a potential issue with other languages then having that as some sort of config option would be the way to go with it disabled by default? Link to comment Share on other sites More sharing options...
Soma Posted August 28, 2011 Share Posted August 28, 2011 I reported an issue 2 days ago that is something similar when creating page manually: https://github.com/ryancramerdesign/P21/issues/41 you could enter more replace functions to your need. Link to comment Share on other sites More sharing options...
ryan Posted August 29, 2011 Share Posted August 29, 2011 There are problems with PW adding words in this manner, like apeisa mentioned. But I can see that people will want to have different approaches for automatic page name generation. So perhaps this is a good area for us to make more easily hookable. Link to comment Share on other sites More sharing options...
Pete Posted August 31, 2011 Author Share Posted August 31, 2011 I think that the best thing for this now that I've thought about it a bit more would be to manage this stuff with some sort of languages module further down the line (think I read that a future version is going to have a multilingual focus in terms of translations). In that case, aside from being able to translate the admin language it would be helpful if there was a section that you could configure through a configuration page for replacements for title-to-url, so that for each language pack you can specify characters and their replacements on that config page rather than doing it in a file. On second thoughts, maybe do it all in a file as it's probably easier to have the rest of the language strings in a file...? Just have an array for title-to-url -specific stuff and an array for language strings maybe? Just thinking out loud Link to comment Share on other sites More sharing options...
ryan Posted August 31, 2011 Share Posted August 31, 2011 Pete, take a look at /wire/modules/Inputfield/InputfieldPageTitle/InputfieldPageTitle.js in the latest commit. Yesterday I added the ability for it to do single-to-multi char replacements, specific to some German characters that Soma (issue #41) found weren't translating correctly. But the same approach could be used to convert '&' to '-and-', just by adding it to the 'srch' and 'repl' arrays in there. I would go ahead and add the '-and-' in there if I could assume the language was English, so I think you are right that we may eventually need a multi-language support solution for this. Link to comment Share on other sites More sharing options...
Pete Posted August 31, 2011 Author Share Posted August 31, 2011 Cheers ryan, I'll check that out Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now