Page 1 of 3

Is possible to know if a category has unread forums ?

Posted: Mon Feb 18, 2008 11:05 pm
by njs
Hello

I've just made the registration now, but I've been reading these forums for a long time.

Regarding styling I'd like to know if there's any style variable to check if a category or level 1 forum has unread foruns in it. I'd like to change the color of the topic title if there's unread forums.

Is it possible ?

I'm "fluent" at PHP and HTML :D Don't feel ashamed to start throwing code eheheh

Kind regards to all .
Nuno

Re: Is possible to know if a category has unread forums ?

Posted: Mon Feb 18, 2008 11:23 pm
by njs
Let me just add that I've used forumrow.S_UNREAD_FORUM without any success.. :D

Re: Is possible to know if a category has unread forums ?

Posted: Tue Feb 19, 2008 3:12 pm
by njs
ideas anyone ? :(

Is it possible ?

Nuno

Re: Is possible to know if a category has unread forums ?

Posted: Tue Feb 19, 2008 4:46 pm
by Raimon
You could use the
forumrow.S_UNREAD_FORUM
change on forumlist_body.html

this:

Code: Select all

<a href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}</a><br />
to:

Code: Select all

<!-- IF forumrow.S_UNREAD_FORUM --><a style="color: #FF0000;" href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}</a>
					<!-- ELSE -->
					       <a href="{forumrow.U_VIEWFORUM}" class="forumtitle">{forumrow.FORUM_NAME}</a>
					<!-- ENDIF -->	   
				     <br />

Re: Is possible to know if a category has unread forums ?

Posted: Tue Feb 19, 2008 8:14 pm
by njs
That's exactly what I've tried, but it didn't work.

Are you sure that a category like p.e. in the case of this forum, "phpBB 3.0.x" when viewing the board index is set to S_UNREAD_FORUM whenever there's unread messages in it ? Or even when viewing only its subforms on its own page ?

Regarding what I've tried I couldn't get it to work :(

Thanks for answering
Nuno

Re: Is possible to know if a category has unread forums ?

Posted: Thu Feb 21, 2008 12:47 pm
by .love^
As far as if it's only concern is subforums & not categories I have yet to try. Though for subforum purposes at least I tried with:

Code: Select all

    <a href="{forumrow.U_VIEWFORUM}" class="forumtitle" <!-- IF forumrow.S_UNREAD_FORUM -->style="color: #FF6600"<!-- ENDIF -->>{forumrow.FORUM_NAME}</a>
And it works. Also tried it with Raimon's code above, and it worked out just fine.

Re: Is possible to know if a category has unread forums ?

Posted: Thu Feb 21, 2008 3:12 pm
by njs
Hi .love^ (wierd post start ;))

Thanks for your comment.

For forums and subforums that solution workd, but it doesn't, or at least I couldn't make it, work for categories.

Example:
phpBB 3.0.x [Category]
|--3.0.x Styles Forums [Forum]
|----[3.0.x] Styles Development & Discussion [Sub-Forums]

If you use that suggestion in the "phpBB 3.0.x" and there's a new message in "3.0.x Styles Forums" it simples doesn't work. Could it be a bug in phpBB ? Or is this not really supposed to work ? ;)

Regards,
Nuno

Re: Is possible to know if a category has unread forums ?

Posted: Thu Feb 21, 2008 5:30 pm
by Muad''Dib
I am also looking for something like this, and i even have been posting about it in the thread below:

http://www.phpbb.com/community/viewtopi ... 9&t=586492

Doesnt seem like its something that is very easy to do with categories!

Re: Is possible to know if a category has unread forums ?

Posted: Thu Feb 21, 2008 5:48 pm
by njs
Hi Muad''Dib,

I thought that on phpBB3 the categories were treated as forums as well.. It seems they aren't.

This would be a really great feature, maybe some hack in the php code could set a variable so that in the template we could do it.. Maybe I'll have a look at it.. I just thought that there might be some solution available.

Regards,
Nuno

Re: Is possible to know if a category has unread forums ?

Posted: Sun Mar 02, 2008 10:21 pm
by njs
I managed to find a solution, but I don't know if it is the best one.. but IT Works.

Here it goes:

I've changed the includes/function_display.php:
Around Line 315 I've added a line which is commented below:

Code: Select all

// Used to tell whatever we have to create a dummy category or not.
$last_catless = true;
$forum_rows_copy = $forum_rows; // Get a copy to not mess up the original $forum_rows
foreach ($forum_rows as $row)
    
A few lines afterward there's.

Code: Select all

// Empty category
if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT)
{
   
I've added the following:

Code: Select all

$cat_unread = false;
foreach ($forum_rows_copy as $frows)
{
    if ($frows['parent_id'] == $row['forum_id'])
    {
        $cat_unread = (isset($forum_tracking_info[$frows['forum_id']]) && $frows['orig_forum_last_post_time'] > $forum_tracking_info[$frows['forum_id']]) ? true : false;
    }
    if ($cat_unread) break;
}
   
And a few lines below, after:

Code: Select all

'S_IS_CAT'                => true,
   
Add:

Code: Select all

'S_UNREAD_FORUM'        => $cat_unread,
   
Then you can use {forumrow.S_UNREAD_FORUM} in the template to check if the category has unread topics.

Is this clear enough ?

Regards,
Nuno

Re: Is possible to know if a category has unread forums ?

Posted: Mon Mar 03, 2008 4:32 pm
by Muad''Dib
njs wrote:I managed to find a solution, but I don't know if it is the best one.. but IT Works.

Here it goes:

I've changed the includes/function_display.php:
Around Line 315 I've added a line which is commented below:

Code: Select all

// Used to tell whatever we have to create a dummy category or not.
$last_catless = true;
$forum_rows_copy = $forum_rows; // Get a copy to not mess up the original $forum_rows
foreach ($forum_rows as $row)
    
A few lines afterward there's.

Code: Select all

// Empty category
if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT)
{
   
I've added the following:

Code: Select all

$cat_unread = false;
foreach ($forum_rows_copy as $frows)
{
    if ($frows['parent_id'] == $row['forum_id'])
    {
        $cat_unread = (isset($forum_tracking_info[$frows['forum_id']]) && $frows['orig_forum_last_post_time'] > $forum_tracking_info[$frows['forum_id']]) ? true : false;
    }
    if ($cat_unread) break;
}
   
And a few lines below, after:

Code: Select all

'S_IS_CAT'                => true,
   
Add:

Code: Select all

'S_UNREAD_FORUM'        => $cat_unread,
   
Then you can use {forumrow.S_UNREAD_FORUM} in the template to check if the category has unread topics.

Is this clear enough ?

Regards,
Nuno
Its clear, however, im not fluent enough yet with PHP or phpbb3 to beable to know where to start to use {forumrow.S_UNREAD_FORUM} .

Re: Is possible to know if a category has unread forums ?

Posted: Mon Mar 03, 2008 4:51 pm
by njs
The {forumrow.S_UNREAD_FORUM} can be used in the forum_list.html in the style/templates directory.

There should be something like

{forumrow.S_IS_CAT} somewhere and afterwars for instance in the {forumrow.FORUM_NAME} you can replace it with whatever you want based on that condition.

Example:
find forumrow.S_IS_CAT
find {forumrow.FORUM_NAME}
replace {forumrow.FORUM_NAME} with

Code: Select all

<!-- IF forum.S_UNREAD_FORUM -->   
<span style="color:#FF0000">{forumrow.FORUM_NAME}</span>
<!-- ELSE -->
{forumrow.FORUM_NAME}
<!-- END -->
I've made it from the top of my head, I don't have access to code right now. Forgive me if there's any mistake in here.

Regards,
Nuno

Re: Is possible to know if a category has unread forums ?

Posted: Tue Mar 04, 2008 11:30 pm
by Muad''Dib
njs wrote:The {forumrow.S_UNREAD_FORUM} can be used in the forum_list.html in the style/templates directory.

There should be something like

{forumrow.S_IS_CAT} somewhere and afterwars for instance in the {forumrow.FORUM_NAME} you can replace it with whatever you want based on that condition.

Example:
find forumrow.S_IS_CAT
find {forumrow.FORUM_NAME}
replace {forumrow.FORUM_NAME} with

Code: Select all

<!-- IF forum.S_UNREAD_FORUM -->   
<span style="color:#FF0000">{forumrow.FORUM_NAME}</span>
<!-- ELSE -->
{forumrow.FORUM_NAME}
<!-- END -->
I've made it from the top of my head, I don't have access to code right now. Forgive me if there's any mistake in here.

Regards,
Nuno
So something like:

open /styles/prosilver/template/forumlist_body.html and find:

Code: Select all

<dt><!-- IF forumrow.S_IS_CAT --><a href="{forumrow.U_VIEWFORUM}">{forumrow.FORUM_NAME}</a><!-- ELSE -->{L_FORUM}<!-- ENDIF --></dt>
replace with:

Code: Select all

<dt><!-- IF forumrow.S_IS_CAT --><a href="{forumrow.U_VIEWFORUM}"><!-- IF forum.S_UNREAD_FORUM --><span style="color:#FF0000">{forumrow.FORUM_NAME}</span><!-- ELSE -->{forumrow.FORUM_NAME}<!-- ENDIF --></a><!-- ELSE -->{L_FORUM}<!-- ENDIF --></dt>
Looks correct to me, but all that seems to do is change the color of the category name. Id like to actually change the color of the whole category row.

Re: Is possible to know if a category has unread forums ?

Posted: Thu Mar 06, 2008 3:47 pm
by njs
For that you would have to define a new css style and apply the style you want according to that variable.. Now the sky is the limit in here :D ehehe

Kind regards,
Nuno

Re: Is possible to know if a category has unread forums ?

Posted: Thu Mar 06, 2008 7:27 pm
by K2-Kelly
deleted by user