[SOLVED] .htaccess News Manager + I18N setup - Printable Version +- GetSimple Support Forum (http://get-simple.info/forums) +-- Forum: GetSimple (http://get-simple.info/forums/forumdisplay.php?fid=3) +--- Forum: General Questions and Problems (http://get-simple.info/forums/forumdisplay.php?fid=16) +--- Thread: [SOLVED] .htaccess News Manager + I18N setup (/showthread.php?tid=4659) |
[SOLVED] .htaccess News Manager + I18N setup - TeeJay - 2013-04-21 Hello, I finally got my custom url structure working but I need special rules for the News Manager. My .htaccess looks like this Code: # News Manager What it does is that if the site is currently in the Czech language (the default language), a page's URL is like this Code: http://mydomain.com/newspage Code: http://mydomain.com/en/newspage The problems is that the News Manager's .htaccess line are only for the default language with the default URL structure without any /en/. So after clicking onto some of the news it works only if my site is currently in the default language, if it's in the secondary, I got page not found error from the NM. What I need is some condition I could implement into my .htaccess to make the NM posts work for both addresses (with and without /en/ in the structure). My thought is something like this Code: # News Manager My current programming project is a java calculator, I'm not good at that, I'm even worse in PHP and I don't understand how .htaccess work at all. So sorry that I can't help myself with this. I would really appreciate your help. Thank you. Tom Edit:// I have just tried deleting both conditionals and just keeping both URL structures for Czech and English and it works a bit. What it does with the settings below is that after clicking onto a post on the News Manager page it switches the site to the secondary language, English, and then shows the article. Obviously it doesn't switch the language back after leaving the News manager article. If I change the order of the NM rewrite rules, nothing changes. Code: # News Manager nastaveni: Edit2:// I have also tried some advice from the Wiki, which is... Code: url.rewrite-once = ( Code: url.rewrite-once = ( RE: .htaccess News Manager + I18N setup - Carlos - 2013-04-22 I suppose it can be done in a better way (I don't know much about rewriterules), but after doing some tests, this works for me: Code: #... News Manager's "Posted on ..." and "Go back to previous page" strings are always displayed in the default language, however. But links to posts work in both languages (without patching NM!) RE: .htaccess News Manager + I18N setup - TeeJay - 2013-04-22 (2013-04-22, 05:05:28)Carlos Wrote: I suppose it can be done in a better way (I don't know much about rewriterules), but after doing some tests, this works for me:Thank you, that's nice that you set that up directly for my lang choice. I tried your setup exactly as you proposed (I copied that) and there are still some errors you 1) didn't have, or, 2) failed to notice. If the site is set to be in English, everything is ok. However, if it's in Czech, the title page switches me to English and can't be switched back to Czech until leaving the title page. Furthermore, the same happens with a post. When I click onto any of the posts, I'm switched to English and switching into Czech returns me to the page with the posts list and excerpts (clanky). Of course I don't have the NM patched, don't you worry. I had better checked the functions.php once more and it's not applied, so it's correct. Edit:// If I add RewriteRule ^/?$ cs/ [R,L] # optional in above the permalink structure setup in the .htaccess I get "Page not found" like from the NM. This RewriteRule adds /cs/ to your title page URL and makes your site Czech (after visit with the root url) until you manually switch to English. RE: .htaccess News Manager + I18N setup - Carlos - 2013-04-22 Did you change get_header by get_i18n_header, and get_navigation by get_i18n_navigation in your template? My tests have been done with Spanish (es) as default language but I edited it for you :-) BTW I've used GS 3.1.2. I'll try with 3.2 RE: .htaccess News Manager + I18N setup - TeeJay - 2013-04-22 (2013-04-22, 06:04:32)Carlos Wrote: Did you change get_header by get_i18n_header, and get_navigation by get_i18n_navigation in your template?I was using get_header, so now I changed to get_i18n_header but nothing changed. I'm using Code: <?php get_i18n_navigation(get_parent(0)==''?return_page_slug():get_parent(0),0,0); ?> I'm using 3.2. RE: .htaccess News Manager + I18N setup - Carlos - 2013-04-22 Just upgraded my test site to 3.2.0 and it works ok. Do you have set cs as default language in View All Pages (I18N) ? RE: .htaccess News Manager + I18N setup - TeeJay - 2013-04-22 (2013-04-22, 06:18:55)Carlos Wrote: Just upgraded my test site to 3.2.0 and it works ok.If you mean this, and I think you mean, then yes. Btw after I started using get_i18n_header(); my homepage crashed even in English because I have a jquery slideshow there which is loaded via get_header only thanks to using FancyBox plugin and also gallery stopped working (clearly because of not loading jquery). Never mind, I can use I18N Gallery instead and load jquery manually with a link. Edit:// Reuploading the site to a free hosting for you to see... Edit2:// Look http://websimple.cz/demo/testTeeJay/plus/ RE: .htaccess News Manager + I18N setup - TeeJay - 2013-04-22 I finally got it working this morning. To prevent the site from switching from Czech to English after clicking onto a post, I had to add &lang=cs behind every "Czech" NM line of .htaccess. It looks like this now. Code: # News Manager nastaveni: And to not get any error on the title page, I had to keep both (cs|en) in the end of the .htaccess. So it looks like this Code: # To make custom permalinks work with the secondary language in the address only :) Permalink structure: %nondefaultlanguage%/%parent%/%slug%/ I don't really know why did it work for you the way you proposed it and not for me. I'm using get_header(false) again, it's the same as the get_i18n_header except the cannonical link with "en" at the end and doesn't affect anything else. I don't really know why does "&lang=cs" have to be in the .htaccess, it's already set up in the admin panel (see the picture above). Never mind. Important is that your "&lang=en" and my "&lang=cs" in the NM lines helped me. That's all that was needed and now it works. Thanks a lot RE: .htaccess News Manager + I18N setup - mvlcek - 2013-04-22 (2013-04-22, 16:36:43)TeeJay Wrote: I finally got it working this morning. The I18N plugin uses two approaches to determine the language. Either the language is included in the URL (lang=xx) or the language is determined from the user's browser's language settings. Thus not specifying the language in the URL for your default language will have it fall back to using the browser settings, which might have "cs" first for one user and "en" first for another user. The default language in the settings is used only, if the browser settings are used, but none of the languages in the browser match the site's languages. RE: .htaccess News Manager + I18N setup - TeeJay - 2013-04-22 (2013-04-22, 16:49:43)mvlcek Wrote: The I18N plugin uses two approaches to determine the language. Either the language is included in the URL (lang=xx) or the language is determined from the user's browser's language settings. I see. That's how it works. Why it worked for Carlos is that he has a Spanish browser and the default language he use is also Spanish. But I have an English browser and use Czech as a default language, so it switches my language only. This is very good to know. Thanks for the explanation Mvlcek. RE: [SOLVED] .htaccess News Manager + I18N setup - Carlos - 2013-04-25 When using a permalink structure containing I18N's %language% or %nondefaultlanguage% tokens, frontend NM links (posts, archives, etc) are rendered properly (thanks to mvlcek's plugin, which is really amazing). However, in NM's backend/admin the "View post" links are broken (not valid). Here's a possible fix. Edit news_manager/inc/functions.php, find this: Code: $url = find_url($NMPAGEURL, $NMPARENTURL); Just after that line, insert this: Code: if (basename($_SERVER['PHP_SELF']) != 'index.php') // back end only @TeeJay Please test. Works for me but I could have missed something. I'll include something like this for NM 2.4.0 RE: [SOLVED] .htaccess News Manager + I18N setup - TeeJay - 2013-04-25 @ Carlos Works perfectly, thanks for that Btw, I occured a little I18N breadcrumbs problem. The whole I18N navigation includes hyperlinks with links to the current page, so I needed also the navigation to NM posts be links. I did this, which works, but there's a little trouble that you can immediately see, I think. Code: <p class="breadcrumbs" > With this, the "»" (the prefix » is also underlined (is a part of the hyperlink. So it's finally consistent with an exception. If I put the "»" outside the function, it would be shown all the time, even if there's nothing behind it. It's embarrasing to have an arrow pointing to an empty space, isn't it? So I would like something IF nm_post_title == NOT EMPTY STRING, THEN show "»" and next to it the hyperlink to nm_post_title. So the hyperlink would be only the post title without the separator "»". Can you write such line for me, please? Thank you. RE: [SOLVED] .htaccess News Manager + I18N setup - Carlos - 2013-04-26 (2013-04-25, 19:06:01)TeeJay Wrote: @ Carlos Thanks for testing. As for your request, I'll answer in the News Manager thread. |