I am unaware of any changes in that area. Was there anything in the changelog?
Support Forum
I had a scour of the changelog and so all I can assume is that my version control is lousy, this is likely because as you know I spend much of my time in a befuddled state. So Andy help me get it working again.
To reiterate.
I have custom group and forum icons
I have the need for iconUnread in group view.
Step1 should be to declare the iconUnread in the array, correct?
I am pretty sure that the previous code worked or I would not have posted it up as a solution.
I really am confused here.
When I use what I think is the correct code then the custom group icons stop working and the iconUnread does not work either.
Here is what I think is the correct code:
<?php
/*
Simple:Press
Template Function Handler
$LastChangedDate: 2012-02-15 17:45:19 -0700 (Wed, 15 Feb 2012) $
$Rev: 7951 $
*/
if (preg_match('#'.basename(__FILE__).'#', $_SERVER['PHP_SELF'])) die('Access denied - you cannot directly call this file');
# ======================================================================================
#
# GROUP VIEW
# Group Loop Functions
#
# ======================================================================================
# --------------------------------------------------------------------------------------
#
# sp_GroupHeaderIcon()
# Display Group Icon
# Scope: Group Loop
#
# --------------------------------------------------------------------------------------
function sp_GroupHeaderIcon($args='') {
global $spThisGroup;
$defs = array('tagId' => 'spGroupHeaderIcon%ID%',
'tagClass' => 'spHeaderIcon',
'icon' => 'sp_GroupIcon.png',
'iconUnread' => 'sp_ForumIcon_new_post.png' ,
'echo' => 1,
'get' => 0,
);
$a = wp_parse_args($args, $defs);
$a = apply_filters('sph_GroupHeaderIcon_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%', $spThisGroup->group_id, $tagId);
# Check if a custom icon
if ($spThisForum->unread) {
$icon = $iconUnread;
$icon = SPTHEMEICONSURL.sanitize_file_name($icon);
}
else if (!empty($spThisForum->forum_icon)) {
$icon = SFCUSTOMURL.$spThisForum->forum_icon;
}
else {
$icon = SPTHEMEICONSURL.sanitize_file_name($icon);
}
if ($get) return $icon;
But you still have not answered the question. You keep saying it doesn’t work but you don’t say in what way it doesn’t work.
then the custom group icons stop working and the iconUnread does not work either.
Whats that if not a description of the problem ![]()
To be more specific when in Group View before I latest upgrade the I had the following functionality:
- custom group Icon
- custom forum icon
- custom iconUnread
When there was a new post in a forum my custom group Icon displayed correctly, and the forum icon changed to the custom iconUnread. If there were no new posts then I would see the custom group icon and custom forum icon. I believe that the code I have posted used to work.
Now what happens is that the custom group icon defaults to the theme default, the custom forum icon still works OK and the iconUnread does not function. I have tried to find a full system backup of the overwritten core file but I use rsync to back up the site and then delete stuff older than a week so I have lost the original file.
Conrad
‘does not work’ does not necessarily mean ‘does not display’. It can mean it displays something else.
Then the code looks fine. So what about the custom unread icon? You have that in the theme folder… is it actually there?
Yes it is there in the current custom theme. Furthermore why does the Group icon set as a custom icon in the admin forum editor cease to display and instead sp_GroupIcon.png is displayed? If I revert to the standard sp-group-view-functions.php file as provided with the current release then the custom icon is displayed.
It is most odd and has me utterly flummoxed.
Conrad
its part of the ‘if’ check… if a custom icon does not exist, that means saved on the group edit panel, the default is used…
Yes but it DOES exist and it is saved on the group edit panel. As I repeatedly keep saying when I use the current default file from the current release version of 5.0 the custom icon displays correctly, that is what I don’t understand. Clearly if it did not exist then the custom icon would not display in this case.
Conrad
Andy is there any possibility that you could try that code on a test site for me today? I’m convinced that something has caused the behaviour of the code to change.
I’m under pressure to get the facility working before launching V5.0 on the live site early next week.
Conrad
OK – I see what you are doing.
This will not now and never would have worked. And that is 100% never.
You are trying to use $spThisForum->unread at the group level. This data object exists at the forum level – NOT group. Even if you made it global and even if it had a pointer to a forum at that point (which it should not have) you would still only interrogate the first forum in the list.
There is no Group level unread flag available and never has been. One would need to loop through each forum in the group to determine if any of them had an unread flag set before this could happen. And it does not happen.
What you did at forum level – which is fine – can not just be replicated on a different data object.
So that code snippet was for the forum view![]()
I did have some working code for group view but it has gone forever by the looks of things and I cannot remember how I did it. I did not loop through each forum though.
So what about using the appearance of sp_ForumStatusPost.png to trigger the use of alternate forum icon in group view?
Could you suggest an easy way of doing that?
I use the same icon for all forums, it is a custom one but it is the same icon. Only the group icons differ for each group.
Conrad
Looping through the forums in a group is the only way to determine the information. And it is what we will basically need to do when and if we build this support in to the core. We just wont do it in the template function.
I have not tried this and really just do not have the time today to do so but you could ty something like this:
global $spGroupView;
$unread = false;
if($spGroupView->forums) {
foreach($spGroupView->forums as $f) {
if($f->unread) $unread=true;
}
}
if($unread) {
# you have some unreadposts it at least one forum within the group
}
At the end there – if the variable $unread is true then you know there is at least one forum with the unread flag set. If I have my code right of course.
Andy I’m really sorry for taking up your time and we are talking at crossed purposes. I did want the forum icon to change if there is an unread post but in group view. Unbelievably I found the working code and here it is:
# Check if a custom icon
if ($spThisForum->unread) {
$icon = $iconUnread;
$icon = SPTHEMEICONSURL.sanitize_file_name($icon);
}
else if (!empty($spThisForum->forum_icon)) {
$icon = SFCUSTOMURL.$spThisForum->forum_icon;
}
else {
$icon = SPTHEMEICONSURL.sanitize_file_name($icon);
}
if ($get) return $icon;
To illustrate what I was actually trying to achieve here is a screen shot.
Conrad_Farlow said
To illustrate what I was actually trying to achieve here is a screen shot.
That’s exactly what I want (or rather, my members ;)), but I can’t figure it out ![]()
Can anybody post which templates to edit, and how, for the latest SP (5.0.3)?
Thank you!

