Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
themes-topic
'iconUnread' in Group View when custom Icon used for forum Icons
Avatar
Conrad_Farlow
Sheffield, UK
Member
Free Members
sp_UserOfflineSmall Offline
Jan 19, 2012 - 3:33 pm

I am using a custom Icon for the forums and I have created another Icon with an indicator to show that there are unread posts in that forum when in group view.

I have used the iconUnread facility in forum view with no problems and copied what I did into spGroupView.php but to no avail.

Here's the code from the relevant section of the sp-group-view-functions.php file. Why is my alternate icon not being displayed? I figure it may have something to do with the first if statement but question

function sp_ForumIndexIcon($args='') {

    global $spThisForum;

    $defs = array('tagId'         => 'spForumIndexIcon%ID%',

                  'tagClass'     => 'spRowIcon',

                  'icon'         => 'sp_ForumIcon.png',

                  'iconUnread'    => 'sp_ForumIcon_new_post.png',

                  'echo'        => 1,

                  'get'            => 0,

                  );

    $a = wp_parse_args($args, $defs);

    $a = apply_filters('sph_ForumIndexIcon_args', $a);

    extract($a, EXTR_SKIP);



    # sanitize before use

    $tagId        = esc_attr($tagId);

    $tagClass    = esc_attr($tagClass);

    $echo        = (int) $echo;

    $get        = (int) $get;



    $tagId = str_ireplace('%ID%', $spThisForum->forum_id, $tagId);



    # Check if a custom icon

    if (!empty($spThisForum->forum_icon)) {

        $icon = SFCUSTOMURL.$spThisForum->forum_icon;

        

    } else {

        if ($spThisForum->unread) $icon = $iconUnread;

        $icon = SPTHEMEICONS.sanitize_file_name($icon);

    }



    if ($get) return $icon;



    $out = "<img id='$tagId' class='$tagClass' src='$icon' alt='' />\n";

    $out = apply_filters('sph_ForumIndexIcon', $out, $a);



    if ($echo) {

        echo $out;

    } else {

        return $out;

    }

Of course the icon is in the theme images folder, the custom icon is still displayed for the forum.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jan 19, 2012 - 8:27 pm

you said you have custom icons...  the code above first checks for that and uses it if it exists... so your check never occurs...

Avatar
Conrad_Farlow
Sheffield, UK
Member
Free Members
sp_UserOfflineSmall Offline
Jan 20, 2012 - 5:04 am

Ah I see it now, the code below works and will insert an icon when there are unread posts whether you have a custom forum icon or not. 

I don't know if it's a good way of doing it or not but if there is a better way I'd like to know it.

    if ($spThisForum->unread) {
        $icon = $iconUnread;
        $icon = SPTHEMEICONS.sanitize_file_name($icon);
    }
    else if (!empty($spThisForum->forum_icon)) {
        $icon = SFCUSTOMURL.$spThisForum->forum_icon;
    }
    else {
        $icon = SPTHEMEICONS.sanitize_file_name($icon);
    }
    
    if ($get) {
        return $icon;
Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 20, 2012 - 6:12 am

Yes - the way things stand at the moment if you have a custom icon set then the same one will be used in all circumstances.

This is a much bigger change than just adding something to a theme template as it would mean a change to the database tables for groups and forums, and changes to the create/edit forum and group forms in the admin so that two custom icons could be applied to items instead of one.

I am not saying it wont happen but it is beyond the scope of V5.0 now in RC. We will revisit though for a future change.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Conrad_Farlow
Sheffield, UK
Member
Free Members
sp_UserOfflineSmall Offline
Jan 20, 2012 - 7:34 am

I'm quite happy to just have it in group view for now Andy. In fact I get so myopic that I'd never even considered other scenarios where I might need it.

Group view was the main one, just to make it consistent with forum view.

I'd better start writing some of this stuff down embarassed

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jan 20, 2012 - 8:34 am

Which should be in last nights update I believe.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Conrad_Farlow
Sheffield, UK
Member
Free Members
sp_UserOfflineSmall Offline
Feb 3, 2012 - 8:41 am

I broke this when I did an svn up. Am I now able to do this in the theme instead of changing the core like I did last time?

Conrad

Avatar
Conrad_Farlow
Sheffield, UK
Member
Free Members
sp_UserOfflineSmall Offline
Feb 3, 2012 - 8:59 am

Forget that I just found the huge thread all about it embarassed

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Feb 3, 2012 - 9:23 am

It should have been done in the theme from when when introduced it. Once in the function code - it is available to the theme...

andy-signature.png
YELLOW
SWORDFISH
Avatar
Propheticus
The Netherlands
Member
Free Members
sp_UserOfflineSmall Offline
Feb 3, 2012 - 2:10 pm

In your code I see: $icon = SPTHEMEICONS.sanitize_file_name($icon);

The SPTHEMEICONS constant no longer exists. You should replace it with SPTHEMEICONSURL and see if that helps.

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625