WordPress.org

Support

Support » Plugins and Hacks » CMS Tree Page View » [Plugin: CMS Tree Page View] Broken when you delete a page

[Plugin: CMS Tree Page View] Broken when you delete a page

Viewing 8 replies - 1 through 8 (of 8 total)
  • I have a similar problem. Don’t know what caused it but I’ve tried deactivating all other plugins and still get the loading icon and ‘Loading…’ without the tree ever loading.

    I get this error in Google Dev Tools

    Uncaught SyntaxError: Unexpected token }
    chrome-extension://ibkclpciafdglkjkcibmohobjkcfkaef/js/code.js:33DOIT http://domain.com/wp-admin/edit.php?post_type=page&page=cms-tpv-page-page

    I tried deleting the plugin, clearing my cache but no luck. 🙁

    I think I may have solved the problem. Based on the javascript error, it looks like a misplaced curly bracket. I’ve made the change below and not had the problem since.

    In the functions.php file within the plugin directory. You need to move the closing curly bracket on line 737 to after the if statement checking for children.

    So from line 737-745…change this:

    }
        <?php
        // if id is in $arrOpenChilds then also output children on this one
        if ($hasChildren && isset($arrOpenChilds) && in_array($onePage->ID, $arrOpenChilds)) {
            ?>, "children": <?php
            cms_tpv_print_childs($onePage->ID, $view, $arrOpenChilds, $post_type);
            ?><?php
        }
    ?>

    To this:

    <?php
        // if id is in $arrOpenChilds then also output children on this one
        if ($hasChildren && isset($arrOpenChilds) && in_array($onePage->ID, $arrOpenChilds)) {
            ?>, "children": <?php
            cms_tpv_print_childs($onePage->ID, $view, $arrOpenChilds, $post_type);
            ?><?php
        }
    ?>
    }

    Clearing my cache/cookies fixed it momentarily, but the bug would inevitably come back. Since making this change I have not had the bug.

    @earnjam – didn’t work for me. Still get exactly the same error 🙁

    Ah, yes I just got it to break again too. It’s just a curly bracket error on the JSON, so I’ll keep looking at it.

    Ok, disregard my comments above. That was completely incorrect. I do however think I solved the problem now. I was on the right track as far as location of the problem, but off in terms of reason.

    The bug showed up for me whenever I had a section expanded, then removed all the children from it. It wanted to stay expanded, but had no children to display. Every time I did that, it would spin forever and not load. I think the if statement on line 740 of the functions.php file that is checking for children to display is the source of the problem.

    I’ve modified that if statement and that seems to have fixed it now. There are better ways to do it, but this was a quick and dirty way until the developers can do a better patch.

    On line 730, replace this:

    "childCount": <?php echo ( isset( $arrChildPages ) ) ? sizeof( $arrChildPages ) : 0 ; ?>,

    with this:

    <?php $childNum = isset( $arrChildPages ) ? sizeof( $arrChildPages ) : 0 ; ?>
    "childCount": <?php echo $childNum ?>,

    Then on that line 740 where the if statement is, replace this:

    if ($hasChildren && isset($arrOpenChilds) && in_array($onePage->ID, $arrOpenChilds)) {

    with this:

    if ($hasChildren && $childNum > 0 && in_array($onePage->ID, $arrOpenChilds)) {

    @earnjam you have earned your jam! Nice quick fix, Lets hope the dev addresses this in a future update.

    So helpful. Worked perfectly for me too. Thanks!

    Seems like you’ve done a lot of work/research to fix this. I’m sorry that I haven’t had the time to fix it myself. I will add this fix to the next update of the plugin. Thanks a lot!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: CMS Tree Page View] Broken when you delete a page’ is closed to new replies.
Skip to toolbar