Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
Greetings again!
I've got a rewrite rule, which works for my non-CouchCMS-managed pages:

RewriteCond %{REQUEST_URI} !(.*(theory).*)
RewriteRule ^(en|ru)/(.*)$ $2?locale=$1 [QSA,NC,L]

So, when I enter:
Code: Select all
http://domain.com/ru/example.php,

the file being launched is: example.php with $_GET['locale']='ru'

When I add these lines to example.php:
Code: Select all
<?PHP require_once 'couch/cms.php'; ?>
<?PHP COUCH::invoke(); ?>


and launch http://domain.com/couch/gen_htaccess.php, then I copy the generated .htaccess lines to my .htaccess with abovementioned rules and the URL becomes:

Code: Select all
http://domain.com/example/?locale=ru


So basically everything works, but I'm not very happy to see ?locale=ru in my browser. For some reason this happens to couchCMS-managed pages only.
The pages I'm speaking about here are placed in root directory and have translations managed via dublicated <cms:editable> sections.

Is there any way to fix this with a RewriteRule?
OK, so here's how I've solved it.
By "solved" I mean that KK's help is needed.
Since I don't like ?locale=en being appended to the end, I've turned of the redirection functionality in CouchCMS:

couch/cms.php, line 337:
Code: Select all
                if( $handle ){
               //MODIFIED BY LADY EKLIPSE
                    if( 1==0/*$redirect_url*/ ){
                        $pg['redirect_url'] = $redirect_url;
                    }
                    else{
                        $pg['mime_type'] = $content_type_header;
                  //$no_cache_tag = "<!--no-cache-->";
                  //$exploded_html = explode($no_cache_tag, $html);
                        //$cached_html = $exploded_html[0].$no_cache_tag.$no_cache_tag.end($exploded_html) . "\n<!-- Cached page";


couch/header.php, line 100:
Code: Select all
                        if( $pg ){
                     //LAME MODIFICATION WARNING. LADY EKLIPSE
                            if( true==false/*$pg['redirect_url']*/ ) {
                                header( "Location: ".$pg['redirect_url'], TRUE, 301 );
                                die();
                            } else {
                                $html = $pg['cached_html'];


What I REALLY need KK's help for is to explain whether I'm losing something extremely important by making this modification and maybe it was possible to do without tinkering around with code?

To clarify, I have a CouchCMS-powered file:

http://site.com/about.php

Here's what I need to have (depending on $_REQUEST['locale']):

http://site.com/ru/about/

Here's what I have:

http://site.com/ru/about/?locale=ru
Hi,

As a developer, I'm firmly in the camp that believes whatever works for you is fine.

That said, if you only wished to stop Couch from redirecting a custom URL to whatever it thinks is the correct URL there is an easier solution -

For v1.4, if you use the following with the closing PHP statement in a template (namely, pass a '1' as parameter), that would turn off Couch's behaviour of always redirecting a page to its 'correct canonical' URL
Code: Select all
<?php COUCH::invoke(1); ?>

If you can upgrade to 1.4.5RC2 (viewtopic.php?f=5&t=8981), the same thing can be done as
Code: Select all
<?php COUCH::invoke(K_IGNORE_CANONICAL_URL); ?>

You can go further and ask Couch to stop even figuring out the page-views, list-views etc by using the following -
Code: Select all
<?php COUCH::invoke(K_IGNORE_CONTEXT); ?>

So now you can actually create your own custom URLs.
I think you'll find the advanced tutorial interesting - http://www.couchcms.com/docs/advanced-tutorial/

Hope it helps :)
3 posts Page 1 of 1