Skip to:
Content
Pages
Categories
Search
Top
Bottom

changing tag list view

  • Hi,

    Currently the tags are displayed in a list like:

    -tag1

    -tag2

    -tag3

    Is it also possible to show them behind each other, saperated by a comma? Like:

    tag1, tag2, tag3. Perhaps with some filter?

    Kind regards,

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

  • chrishajer
    Participant

    @chrishajer

    It looks like the default for that function is a list, but table would also be accepted. But the other choice, table, would just return (i.e., I don’t think they ever finished that, but were maybe planning on having other options.)

    function bb_list_tags( $args = null )
    {
    $defaults = array(
    'tags' => false,
    'format' => 'list',
    'topic' => 0,
    'list_id' => 'tags-list'
    );

    $args = wp_parse_args( $args, $defaults );
    extract( $args, EXTR_SKIP );

    if ( !$topic = get_topic( get_topic_id( $topic ) ) ) {
    return false;
    }

    if ( !is_array( $tags ) ) {
    $tags = bb_get_topic_tags( $topic->topic_id );
    }

    if ( !$tags ) {
    return false;
    }

    $list_id = esc_attr( $list_id );

    $r = '';
    switch ( strtolower( $format ) ) {
    case 'table' :
    break;

    case 'list' :
    default :
    $args['format'] = 'list';
    $r .= '<ul id="' . $list_id . '" class="tags-list list:tag">' . "n";
    foreach ( $tags as $tag ) {
    $r .= _bb_list_tag_item( $tag, $args );
    }
    $r .= '</ul>';
    break;
    }

    echo $r;
    }

    I hope someone else can come along and show how to do this with a plugin.

    Well to be honest, I think some kind of filter has to be created. I need this for a template and it’s kinda weird you have to go this deep to change a display. Sure I can put this in a plugin but then you have to supply this plugin with your template. It’s a small issue but something the dev team should take a look at…. if there is still one…

    Nevertheless, thank you for your suggestion, I’ll try it as soon as I am home.

    Kind regards,

    Hmm this wont work since I need to edit _bb_list_tag_item too. Hmm perhaps I need to write some new code for this. Kinda hoped this could be done easier :)

    Ok I have written a function to get the tags in a row, but I want to have them comma seperated, any ideas?

    function bb_row_tags( $args = null ) {
    $defaults = array(
    'tags' => false,
    'format' => 'row',
    'topic' => 0,
    );

    $args = wp_parse_args( $args, $defaults );
    extract( $args, EXTR_SKIP );

    if ( !$topic = get_topic( get_topic_id( $topic ) ) ) {
    return false;
    }

    if ( !is_array( $tags ) ) {
    $tags = bb_get_topic_tags( $topic->topic_id );
    }

    if ( !$tags ) {
    return false;
    }

    $r = '';
    switch ( strtolower( $format ) ) {
    case 'row' :
    default :
    $args['format'] = 'row';
    foreach ( $tags as $tag ) {
    $r .= _bb_row_tag_item( $tag, $args );
    }
    break;
    }
    echo $r;
    }

    function _bb_row_tag_item( $tag, $args ) {
    $url = esc_url( bb_get_tag_link( $tag ) );
    $name = esc_html( bb_get_tag_name( $tag ) );
    if ( 'row' == $args['format'] ) {
    $id = 'tag-' . $tag->tag_id . '_' . $tag->user_id;
    return "t" . '<a href="' . $url . '" rel="tag">' . $name . '</a>' . "n";
    }
    }

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

You must be logged in to reply to this topic.