Problems, need help? Have a tip or advice? Post it here.
11 posts Page 1 of 2
From what I read I must visit a page in page-view when I want to remove a field in admin panel. But it is impossible to do so because my template has no page-view. It is fitted with custom routes only. Is there a way to overcome this limitation?
You are right about the lack of page context preventing fields from getting deleted.
For now please just remove the K_IGNORE_CONTEXT temporarily to get back the page-view and delete the fields -
<?php COUCH::invoke( K_IGNORE_CONTEXT ); ?>
Thank you! But I when I remove it those fields are still present. It is strange but the template without ignored context remains fully functional. The only difference that urls transform to "?q=X". I have no "k_is_page" in the template because it was not needed(custom routes). Pretty URLs are enabled. Do I need to do any additional steps? It is very inconvenient as I'll need to modify this template a lot soon.
Also worth mentioning that the website is in production now, so I really don't want to mess something :)
If it helps - old(before custom routes) page view links return 404.
Having k_is_page in your template is not essential - the 'page view' still gets triggered if the proper URL is used (for non-prettyURLs it has '?p=x' and for prettyURLs it is like xx.html).

I think what is happening is that since Pretty URLs are activated, the .htaccess rules for custom routes are not calling the correct page-view URL.

Please try the following -
1. deactivate prettyURLs temporarily from couch/config.php
2. now from the admin-panel where you see the listing of pages, click on the magnifying glass icon. This will load the template in page-view (you should now find that the URL of the visited page has the required ?p=x)

That should delete the fields and you can revert back to your original settings.

Please try and let me know how it goes.
Thank you for helping out, but it is not possible to play with htaccess or prettyUrls. The website is in production and has over 1000 pages with tons of redirects because of the old website(pre couch on that domain), some visitors, google bot indexing, etc. I believe If I turn preetyUrls off it would potentially make a bad impact on SEO and visitors satisfaction. Is there any other approach to manage custom routed pages with ease on production? If it was one time solution - thats ok, but I need to modify it from time to time. Again, thank you so much for helping!
but I need to modify it from time to time
You mean to say you plan to add/delete editable regions on a regular basis on a production site? That is not a good idea in any case.

Anyway, I am sorry but I can't think of any other 'safe' way for you to do that on a live site.
It should only take a few moments so if SEO impact etc. is a factor, I suggest you choose a low traffic time and then put the site offline from config.

Hope it helps..
KK wrote:
but I need to modify it from time to time
You mean to say you plan to add/delete editable regions on a regular basis on a production site? That is not a good idea in any case.

What can I do if the customer always wants to restructure something. It would be inefficient to just leave unused fields filled with data in DB.

What if I put this code on production website and just leave it there, so the system treats the template as in constant page-view mode:

Code: Select all
<cms:php>
    global $PAGE, $CTX;

    $CTX->set( 'k_is_home', 0 );
    $PAGE = new KWebpage( '<cms:show k_template_name />', null, '<cms:show rt_page_name/>' );
    $PAGE->set_context();
</cms:php>


Also, I wonder if it can work that way:

Code: Select all
<cms:php>
    global $CTX;

    $CTX->set( 'k_is_home', 0 );
    $CTX->set( 'k_is_page', 1 );
</cms:php>


What negative consequences it could potentially bring?
What can I do if the customer always wants to restructure something.
Of course, I understand. This usually is an infrequent thing to do on an established site, though.

Anyway, I have tried to prepare a solution for you (goes without saying that I assume you are using v2.x).

But first, if you have removed the K_IGNORE_CONTEXT from your custom routed template, as I suggested before, please first put that statement back (i.e. revert back to using the custom routes just as you were before our conversation).
It is also *always* advisable to take a full database backup before attempting any structural changes to the tables (be it Couch or any other software). Do make sure to take one before proceeding.

Ok, now place the following code in your 'couch/addons/kfunctions.php' file -
Code: Select all
// Allow deletion of fields when using custom routes
$FUNCS->add_event_listener( 'post_process_page_start', 'my_post_process_page' );
function my_post_process_page(){
    global $PAGE, $CTX;

    if( $CTX->ignore_context ){
        $PAGE->is_master=0;
    }
}

And now if you visit the template using custom routes as super-admin (in any view), the deleted fields will be processed as in the page-view of normal templates.

Hope this helps. Do let me know.
Provided solution works as expected! It is super convenient now and i'm very happy with a result. Thank you very much!
11 posts Page 1 of 2

Who is online

In total there are 3 users online :: 0 registered, 0 hidden and 3 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 3 guests

cron