vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   Friendly URLs - UTF-8 to ASCII (https://vborg.vbsupport.ru/showthread.php?t=317716)

rudexpunx 03-10-2015 08:31 AM

Friendly URLs - UTF-8 to ASCII
 
Hi,

I'd need to convert all the links on the forum to ASCII (right now, they are in UTF-8 with accents). Basic conversion to base characters would be fine for me. Is there a way to do this in vB4.2.2, or do I have to code it manually?

Note: ASCII urls already work (if I enter manually converted URL in ASCII, vB routes me to the right page), so the only thing I need is actually links modification

Thanks!
Martin

kh99 03-10-2015 09:57 AM

I'm not sure what you mean. There's probably code somewhere that would change accented characters to the closest ASCII, but if you're talking about the actual url, it wouldn't be the same url when you were done.

rudexpunx 03-10-2015 10:09 AM

example:

now a forum link looks like this
Code:

forum/3-????žť
what I want is
Code:

forum/3-ieayzt
This is just a matter of site links, because routing/rewrites work fine for both. I'd prefer to have forum/thread links indexed in ASCII, that's my reason.

Thanks!

kh99 03-10-2015 11:45 AM

Quote:

Originally Posted by rudexpunx (Post 2540013)
This is just a matter of site links, because routing/rewrites work fine for both.

Oh, and now I see where you said that in your first post and I didn't understand. Anyway, there doesn't appear to be any way to do this that's built in to vbulletin. Hopefully someone else will know more about it.

kh99 03-10-2015 01:12 PM

OK, I haven't tested this a lot, but you might try this: I found a function that someone wrote here: https://gist.github.com/evaisse/169594 that replaces accented characters in a string. But since I don't know about the licensing, I won't copy it here. But you can copy it yourself and paste it in to a plugin.

So, you can create a new plugin using hook location friendlyurl_geturl and code like this:
Code:

if (!function_exists('remove_accents'))
{

// Paste copied function here

}
$url=remove_accents($url);


Then go to that site, copy the code (but not the first line that starts with <?php), and paste it where indicated.


Also one other thing, there seems to be a minor bug in that function, so you should find this line:
Code:

if( !function_exists('mb_detect_encoding') ) {

and remove the ! so that it looks like:
Code:

if( function_exists('mb_detect_encoding') ) {

rudexpunx 03-10-2015 04:49 PM

Thank you for the help!

This is what I call honest and quick help. You helped me a lot, and it works pretty good - I'll test it on live forum soon. But so far, I don't see any problem with the code + there is quiet strong coverage of accented characters.

So, again, thanks a lot, Kevin.


All times are GMT. The time now is 08:26 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00993 seconds
  • Memory Usage 1,724KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete