serpentguard1701 (@serpentguard1701)

Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • @serpentguard1701

    Member

    what variables can you retrieve from the global $forum variable?

    @serpentguard1701

    Member

    I first tried switching DESC to ASC, and it didn’t change the result, which was 1.

    @serpentguard1701

    Member

    I had to change topic_time<='$topic->topic_time' to topic_time>='$topic->topic_time', but it works beautifully now.

    I’m thinking about applying this mod to the regular topic view. You told me in a different thread that it should be fine if I’m only using this extra DB query in the Edit screen – do you think it would be unwise to use it in regular topic views?

    @serpentguard1701

    Member

    I tried the shortcut method, it returned an error: `bbPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’01:46:48 ORDER BY topic_time DESC’ at line 1]

    SELECT count(topic_id) as position FROM tvcforum_topics WHERE forum_id=6 and topic_time<=2008-12-09 01:46:48 ORDER BY topic_time DESC`

    Regarding the last bit of code you posted – there’s actually a function already present in one of the bb-includes files that does the same thing – get_page_number().

    @serpentguard1701

    Member

    @_ck_ – The reason is, I have some breadcrumb links in the header of my edit_post.php file. It displays something like this:

    The Volturi’s Castle Forum » Forum Games » Count to 10,000 » Edit Post

    I have the topic link pointing to the exact position of the post being edited, and I want the forum link to point to the exact page of the topic as well. The code I have is this:

    <?php
    $forum_id = $bbdb->get_var("SELECT forum_id FROM $bbdb->posts WHERE post_id=" . get_post_id() . " LIMIT 1");
    $forum_name = get_forum_name($forum_id);
    /*$topic_array = $bbdb->get_var("SELECT topic_id FROM $bbdb->topics WHERE forum_id=" . $forum_id . " ORDER BY topic_time ASC");
    while ($topic_id = current($topic_array))
    if ($topic_id == get_topic_id())
    $topic_index = key($topic_array);
    $forum_page = get_page_number($topic_index);*/
    $forum_link = '<a href="' . get_forum_link($forum_id, $forum_page) . '">' . $forum_name . '</a>';
    ?>
    <a href="<?php bb_option('uri'); ?>"><?php bb_option('name'); ?></a> &raquo; <?php echo $forum_link; ?> &raquo; <a href="<?php post_link(); ?>"><?php topic_title(); ?></a> &raquo; <?php _e('Edit Post','rag'); ?>

    The commented stuff is what’s giving me trouble. When executed, it issues an error saying that $topic_array isn’t an object or array. I inserted an echo $topic_array;, and it spit out 3. The topic_id is 13, the forum_id is 6, and no matter what post I edit, the same number is echoed, so I have no idea where it’s getting 3.

    @serpentguard1701

    Member

    Well, I found this function that’s used by the rss.php file:

    function get_post_link( $post_id = 0 ) {
    $bb_post = bb_get_post( get_post_id( $post_id ) );
    $page = get_page_number( $bb_post->post_position );

    return apply_filters( 'get_post_link', get_topic_link( $bb_post->topic_id, $page ) . "#post-$bb_post->post_id", $bb_post->post_id );
    }

    Is there a forum version fo the italicized portion of this function?

    @serpentguard1701

    Member

    Sweet, works perfectly, thanks.

Viewing 7 replies - 1 through 7 (of 7 total)