WordPress.org

Ready to get started?Download WordPress

Forums

CMS Tree Page View
Broken when you delete a page (9 posts)

  1. almendron
    Member
    Posted 1 year ago #

    1) Deleting a page (draft or publish).
    2) Access menu "CMS Page Tree View" on the dashboard: not loading pages.

    http://wordpress.org/extend/plugins/cms-tree-page-view/

  2. mrjonnywood
    Member
    Posted 1 year ago #

    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. :(

  3. William Earnhardt
    Member
    Posted 1 year ago #

    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.

  4. mrjonnywood
    Member
    Posted 1 year ago #

    @earnjam – didn't work for me. Still get exactly the same error :(

  5. William Earnhardt
    Member
    Posted 1 year ago #

    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.

  6. William Earnhardt
    Member
    Posted 1 year ago #

    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)) {
  7. mrjonnywood
    Member
    Posted 1 year ago #

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

  8. aaronsnow
    Member
    Posted 1 year ago #

    So helpful. Worked perfectly for me too. Thanks!

  9. Pär Thernström
    Member
    Plugin Author

    Posted 1 year ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic