Fork me on GitHub

collapsible blocks  Bottom

  • While using collapsible blocks the whole page gets reloaded which, using current techniques, wouldn't have to be necessary anymore.

    By using this example it is quite easy to make a javascript-collapsable block. Some questions though...

    I included the javascript-function in my theme with:

    Code

    <!--[pnpageaddvar name="javascript" value="javascript/showHide.js"]-->


    Don't all js files in the javascript-subdir get loaded automatically? I assume this isn't the right place to store my js, what would be the right place?

    Also, in my blockfile I included the bid to ensure every block had it's own id:

    Code

    <a href="javascript:ReverseDisplay('approved-<!--[$bid]-->')">&nbsp;<img src="/images/global/upb.gif" /></a></span><h2><!--[$title]--></h2>
        </div>
        <div id="approved-<!--[$bid]-->" class="rsboxblock">


    If I'd do this the right way, I would have to create the code in pnBlocks.php like it's done now, then I can also change the image-source with javascript:

    Code

    if (pnUserLoggedIn() && pnModGetVar('Blocks', 'collapseable') == 1 && isset($row['collapsable']) && ($row['collapsable'] == '1')) {
            if (pnCheckUserBlock($row) == '1') {
                if (!empty($row['title'])) {
                    $row['minbox'] = '<a href="' . DataUtil::formatForDisplay(pnModURL('Blocks', 'user', 'changestatus', array('bid' => $row['bid'], 'authid' => pnSecGenAuthKey()))) . '">' . $upb . '</a>';
                }
            } else {
                $row['content'] = '';
                if (!empty($row['title'])) {
                    $row['minbox'] = '<a href="' . DataUtil::formatForDisplay(pnModURL('Blocks', 'user', 'changestatus', array('bid' => $row['bid'], 'authid' => pnSecGenAuthKey()))) . '">' . $downb . '</a>';
                }
            }
        } else {
            $row['minbox'] = '';
        }


    Where would I store my own version of pnBlocks.php or do I have to alter the core-code?

    Clicking a plus or minus sign in the block calls a new page with an authid. In blocks_user_changestatus() in system/blocks/pnuser.php nothing is done with the authid because it causes errors (commented out). Why would we even want to use authid here, I see no use?

    However, it would be nice to keep the collapsed state.
    Would it be possible to call a PHP-function like blocks-user_changestatus in js which stores the new state without refreshing the whole page (would be an Ajax-like call I guess) ?

    gr

    Bas
  • 0 users

This list is based on users active over the last 60 minutes.