News:

Join the Facebook Fan Page.

Main Menu

i have a function

Started by texasman1979, March 10, 2011, 01:50:04 PM

Previous topic - Next topic

texasman1979

function Fill_Content_Block($rc, $b)
{
    global $context, $board_info, $smcFunc, $scripturl;

    $board = isset($b) ? $b : empty($board_info['id']) ? 'forum' : $board_info['id'];

    $rdb = $smcFunc['db_query']('', '
        SELECT content
        FROM {db_prefix}content_blocks
        WHERE reg_code = {string:rc} AND board_id = {string:b_id}',
        array(
            'rc' => isset($rc) ? $rc : $context['active_rc']['reg_code'],
            'b_id' => $board,
            )
    );
   
    $row = $smcFunc['db_num_rows']($rdb) > 0 ? $smcFunc['db_fetch_assoc']($rdb) : false;
    $smcFunc['db_free_result']($rdb);

    $context['forBlock']['content'] = $row != false ? $row['content'] : 'some content.';

    if (isset($rc, $b))
        return;

    if (isset($board_info['id']))
        if (isset($board_info['parent']) && $board_info['child_level'] > 0)
            $context['forBlock']['header'] = $board_info['parent_boards'][$board_info['parent']]['name'] . ' - ' . $board_info['name'];
        else
            $context['forBlock']['header'] = $board_info['cat']['name'] . ' - ' . $board_info['name'];
    else
        $context['forBlock']['header'] = 'Myfewclicks.com Discussion Forum';

    $url = 'http://www.myfewclicks.com/CBE.php?rc=' . $context['active_rc']['reg_code'] . '&b=' . $board;

    $context['forBlock']['footer'] = !$context['user']['is_admin'] ? '' : '
        <div style="float:right">
            <br class="clear" /><br class="clear" />
            <a href="' . $url . '">Edit This!</a>
        </div>
        ';
}


when called from:
Fill_Content_Block(null, null);
it appears to work fine.

when called from:
Fill_Content_Block($_GET['rc'], $_GET['b']);
it appears to cause me a headache.

im going to brake a bit, if yall can see something please let me know. :)

i beleive this line:
$board = isset($b) ? $b : empty($board_info['id']) ? 'forum' : $board_info['id'];

and this line:
'rc' => isset($rc) ? $rc : $context['active_rc']['reg_code'],
is causeing the headache, not sure why tho.
SMF 2.0.4
SimplePortal 2.3.5

LOGIC is a FOUR letter word! :)


Matthew K.

Didn't review the whole code, but try this: function Fill_Content_Block($rc = '', $b = '')

Also, those two lines you thought were causing the problem, instead of isset() try !empty(). They're always going to be SET, since they're passed through the function, but what you really want to know is if they are empty, or not.

texasman1979

SMF 2.0.4
SimplePortal 2.3.5

LOGIC is a FOUR letter word! :)


Advertisement: