Is possible to know if a category has unread forums ?

For support and discussion related to templates, themes, and imagesets in phpBB 3.0.
Scam Warning
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

Is possible to know if a category has unread forums ?

Post 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
Last edited by njs on Thu Feb 21, 2008 3:13 pm, edited 1 time in total.
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

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

Post by njs »

Let me just add that I've used forumrow.S_UNREAD_FORUM without any success.. :D
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

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

Post by njs »

ideas anyone ? :(

Is it possible ?

Nuno
User avatar
Raimon
Former Team Member
Posts: 12088
Joined: Tue May 30, 2006 5:31 pm
Location: Netherlands
Name: Raimon Meuldijk
Contact:

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

Post 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 />
Need phpBB installation, extenstions, Styles or integrate phpBB with you website?
Contact me @ www.raimon.nl for fair prices and good service!
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

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

Post 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
User avatar
.love^
Registered User
Posts: 4
Joined: Mon Feb 18, 2008 3:40 am
Location: Lund, Sweden
Contact:

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

Post 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.
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

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

Post 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
User avatar
Muad''Dib
Registered User
Posts: 311
Joined: Tue Jun 12, 2007 6:20 pm
Contact:

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

Post 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!
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

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

Post 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
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

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

Post 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
User avatar
Muad''Dib
Registered User
Posts: 311
Joined: Tue Jun 12, 2007 6:20 pm
Contact:

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

Post 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} .
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

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

Post 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
User avatar
Muad''Dib
Registered User
Posts: 311
Joined: Tue Jun 12, 2007 6:20 pm
Contact:

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

Post 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.
njs
Registered User
Posts: 92
Joined: Mon Feb 18, 2008 10:59 pm
Location: Aveiro, Portugal

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

Post 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
K2-Kelly
Registered User
Posts: 83
Joined: Thu Feb 14, 2008 5:38 am
Location: U.S./Jamaica W.I.

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

Post by K2-Kelly »

deleted by user
Locked

Return to “[3.0.x] Styles Support & Discussion”