[2.0.19] Forum Icon with ACP Control

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
36
60%
Very Good
14
23%
Good
6
10%
Fair
2
3%
Poor
2
3%
 
Total votes: 60

User avatar
Freitag
Registered User
Posts: 143
Joined: Mon Jul 11, 2005 10:17 pm

Post by Freitag » Mon Mar 27, 2006 4:23 am

I wanted to have a random icon appear instead of a fix icon so I made the following changes.

in the file index.php locate the line of code that is:

Code: Select all

$template->assign_block_vars('catrow.forumrow', array(
(it is line 485 in my file)

insert the following code before that line:

Code: Select all

$ri_temp1 = '<img src="' . $phpbb_root_path . $icon . '" alt="'.$forum_data[$j]['forum_name'].'" title="'.$forum_data[$j]['forum_name'].'" border="0" />';
if( strstr( $icon, "[" ) )
{
preg_match( "/\[(\d)-(\d)\]/", $ri_temp1, $beans );
$ri_num = rand($beans[1], $beans[2]);
$ri_base = substr( $icon, 0, strpos( $icon, "[" ) );
$ri_suffix = substr( $icon, strpos( $icon, "]" )+1 );
$ri_temp1 = '<img src="' . $phpbb_root_path . $ri_base . $ri_num . $ri_suffix . '" alt="'.$forum_data[$j]['forum_name'].'" title="'.$forum_data[$j]['forum_name'].'" border="0" />';
}
$ri_temp2 = $ri_temp1;
Next locate the line of code that is:

Code: Select all

                'FORUM_ICON_IMG' => ($icon) ? '<img src="' . $phpbb_root_path . $icon . '" alt="'.$forum_data[$j]['forum_name'].'" title="'.$forum_data[$j]['forum_name'].'" border="0" />' : '', // Forum Icon Mod
and replace it with the following line of code:

Code: Select all

'FORUM_ICON_IMG' => ($icon) ? $ri_temp2 : '', // Forum Icon Mod
First upload several images like so..
icon_name1.png
icon_name2.png
icon_name3.png
icon_name4.png
icon_name5.png


Then in the Forum control panel where you add the link to the forum icon, add the link in the following format:
images/icon_name[1-5].png

The square brackets are the flag that you have multiple files. The hyphen designated the range. Any suffix will work

When your forum page refreshes one of the images will be chosen at random each time.

The icon in the main control panel will be broken, but in the forum it will work. I'll post a patch for the control panel later (but it will essentially be the same code)

User avatar
Freitag
Registered User
Posts: 143
Joined: Mon Jul 11, 2005 10:17 pm

Post by Freitag » Mon Mar 27, 2006 6:00 am

Here is the code for the forum control panel.

In the file admin_forum.php find the line that is:

Code: Select all

      $template->assign_vars(array(
And insert this code before it:

Code: Select all

      $ri_temp1 = '<img src="' . $phpbb_root_path . $forumicon . '" />';
      if( strstr( $forumicon, "[" ) )
      {
        preg_match( "/\[(\d)-(\d)\]/", $forumicon, $beans );
        $ri_num = rand($beans[1], $beans[2]);
        $ri_base = substr( $forumicon, 0, strpos( $forumicon, "[" ) );
        $ri_suffix = substr( $forumicon, strpos( $forumicon, "]" )+1 );
        $ri_temp1 = '<img src="' . $phpbb_root_path . $ri_base . $ri_num . $ri_suffix . '" />';
      }
      $ri_temp2 = $ri_temp1;
Then locate the code:

Code: Select all

        'ICON_DISPLAY' => ( $forumicon ) ? '<img src="' . $phpbb_root_path . $forumicon . '" />' : '' // Forum Icon MOD 
And replace it with:

Code: Select all

        'ICON_DISPLAY' => ($forumicon) ? $ri_temp2 : '', // Forum Icon Mod


Next find the line that is:

Code: Select all

$template->assign_block_vars("catrow.forumrow", array(
And insert this code before it:

Code: Select all

        $icon = $forum_rows[$j]['forum_icon'];
        $ri_temp1 = '<img src="' . $phpbb_root_path . $icon . '" alt="'.$forum_data[$j]['forum_name'].'" title="'.$forum_data[$j]['forum_name'].'" border="0" />';
        if( strstr( $icon, "[" ) )
        {
          preg_match( "/\[(\d)-(\d)\]/", $ri_temp1, $beans );
          $ri_num = rand($beans[1], $beans[2]);
          $ri_base = substr( $icon, 0, strpos( $icon, "[" ) );
          $ri_suffix = substr( $icon, strpos( $icon, "]" )+1 );
          $ri_temp1 = '<img src="' . $phpbb_root_path . $ri_base . $ri_num . $ri_suffix . '" alt="'.$forum_data[$j]['forum_name'].'" title="'.$forum_data[$j]['forum_name'].'" border="0" />';
        }
        $ri_temp2 = $ri_temp1;

Then find the line that is:

Code: Select all

          'FORUM_ICON_IMG' => ( $forum_rows[$j]['forum_icon'] ) ? '<img src="' . $phpbb_root_path . $forum_rows[$j]['forum_icon'] . '" alt="'.$forum_data[$j]['forum_name'].'" title="'.$forum_data[$j]['forum_name'].'" border="0" />' : '', // Forum Icon Mod
And replace it with:

Code: Select all

'FORUM_ICON_IMG' => ( $forum_rows[$j]['forum_icon'] ) ? $ri_temp2 : '', // Forum Icon Mod

User avatar
Freitag
Registered User
Posts: 143
Joined: Mon Jul 11, 2005 10:17 pm

Post by Freitag » Mon Mar 27, 2006 6:33 am

Here is the code for viewforum.php

Find the line of code that says:

Code: Select all

$template->assign_vars(array(
And insert the following code ahead of it:

Code: Select all

$icon = $forum_row['forum_icon'];
$ri_temp1 = '<img src="' . $phpbb_root_path . $icon . '" alt="'.$forum_data[$j]['forum_name'].'" title="'.$forum_data[$j]['forum_name'].'" border="0" />';
if( strstr( $icon, "[" ) )
{
  preg_match( "/\[(\d)-(\d)\]/", $ri_temp1, $beans );
  $ri_num = rand($beans[1], $beans[2]);
  $ri_base = substr( $icon, 0, strpos( $icon, "[" ) );
  $ri_suffix = substr( $icon, strpos( $icon, "]" )+1 );
  $ri_temp1 = '<img src="' . $phpbb_root_path . $ri_base . $ri_num . $ri_suffix . '" alt="'.$forum_data[$j]['forum_name'].'" title="'.$forum_data[$j]['forum_name'].'" border="0" />';
}
$ri_temp2 = $ri_temp1;
Then find the line:

Code: Select all

  'FORUM_ICON_IMG' => ($forum_row['forum_icon']) ? '<img src="' . $phpbb_root_path . $forum_row['forum_icon'] . '" alt="'.$forum_row['forum_name'].'" title="'.$forum_row['forum_name'].'" border="0" />&nbsp;' : '', // Forum Icon Mod
and replace it with:

Code: Select all

  'FORUM_ICON_IMG' => ($icon) ? $ri_temp2 : '', // Forum Icon Mod
And I believe you are all done...

MadCab
Registered User
Posts: 4
Joined: Wed Apr 12, 2006 10:01 am

Post by MadCab » Wed Apr 12, 2006 10:07 am

Hi.
Could anyone please tell me what i'm doing wrong here?

i'm not sure what SQL is, so i don't know how it works.
Thank you! :(

Image

Image

Image

MadCab
Registered User
Posts: 4
Joined: Wed Apr 12, 2006 10:01 am

Post by MadCab » Wed Apr 12, 2006 10:18 am

ok, i forgot to add ; tipicaly i figure it out just after posting. :roll:
everything works great now.
sorry.

Viper07
Registered User
Posts: 85
Joined: Mon Jan 16, 2006 8:34 pm

Post by Viper07 » Sat Apr 29, 2006 6:29 pm

Freitag wrote: Is your probelm install related or post-install?

If it is install related then the fix I used might work directly for you (several posts back).

If it doesn't work directly, then it might work indirectly. Copy the text that is actually in your .tpl file into the MOD file so that it can find exactly what you have with it's "FIND" and "IN-LINE FIND" commands.

If it is post-install I think we need more description of the problem to be able to help.


It is post install.

I have this in index_body.tpl:

Code: Select all

<td class="row1" align="center" valign="middle" style="padding: 5px;"><img src="{catrow.forumrow.FORUM_FOLDER_IMG}" width="24" height="24" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" /></td>
	<td class="row1" width="100%"><span class="forumlink"> <a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">{catrow.forumrow.FORUM_NAME}</a><br />
	  </span> <span class="genmed">{catrow.forumrow.FORUM_DESC}<br />
	  </span><!-- IF catrow.forumrow.MODERATORS --><span class="gensmall">{catrow.forumrow.L_MODERATOR} <i>{catrow.forumrow.MODERATORS}</i><br /></span><!-- ENDIF -->
	  <!-- BEGIN sub --><!-- DEFINE $HAS_SUB = 1 --><!-- IF catrow.forumrow.sub.NUM > 0 -->, <!-- ELSE --><span class="genmed">{L_SUBFORUMS}: <!-- ENDIF -->{catrow.forumrow.sub.LAST_POST_SUB} <a href="{catrow.forumrow.sub.U_VIEWFORUM}" <!-- IF catrow.forumrow.sub.UNREAD -->class="topic-new"<!-- ENDIF --> title="{catrow.forumrow.sub.FORUM_DESC_HTML}">{catrow.forumrow.sub.FORUM_NAME}</a><!-- END sub -->
	  <!-- IF $HAS_SUB --></span><!-- UNDEFINE $HAS_SUB --><!-- ENDIF -->
	</td>
	<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.TOTAL_TOPICS}</span></td>
	<td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.TOTAL_POSTS}</span></td>
	<td class="row1" align="center" valign="middle" nowrap="nowrap"><span class="gensmall">{catrow.forumrow.LAST_POST}</span></td>
And I need to find this:

Code: Select all

<td class="row1" width="100%" height="50"><span class="forumlink"> <a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">{catrow.forumrow.FORUM_NAME}</a><br />
	  </span> <span class="genmed">{catrow.forumrow.FORUM_DESC}<br />
	  </span><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span></td>
And replace it with:

Code: Select all

<td class="row1" width="100%" height="50"><table width="100%" cellpadding="2" cellspacing="0" border="0">
		<tr><td><a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">{catrow.forumrow.FORUM_ICON_IMG}</a></td>
			<td width="100%"><span class="forumlink"><a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">{catrow.forumrow.FORUM_NAME}</a><br />
  				</span> <span class="genmed">{catrow.forumrow.FORUM_DESC}<br />
  				</span><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span>
  			</td>
  		</tr>
  	</table></td>
But I can't get around it, and It messes up my forum when trying.

User avatar
Freitag
Registered User
Posts: 143
Joined: Mon Jul 11, 2005 10:17 pm

Post by Freitag » Sat Apr 29, 2006 7:38 pm

Try replacing that whole block with...

Code: Select all

  <td class="row1" align="center" valign="middle" height="50"><img src="{catrow.forumrow.FORUM_FOLDER_IMG}" width="46" height="25" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" /></td>
  <td class="row1" width="100%" height="50">
  <table width="100%" cellpadding="2" cellspacing="0" border="0"><tr><td><a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">{catrow.forumrow.FORUM_ICON_IMG}</a></td><td width="100%">
  <span class="forumlink"> <a href="{catrow.forumrow.U_VIEWFORUM}" class="forumlink">{catrow.forumrow.FORUM_NAME}</a><br />
    </span> <span class="genmed">{catrow.forumrow.FORUM_DESC}<br />
<!-- IF catrow.forumrow.MODERATORS --><span class="gensmall">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}<br /></span><!-- ENDIF -->
    <!-- BEGIN sub --><!-- DEFINE $HAS_SUB = 1 --><!-- IF catrow.forumrow.sub.NUM > 0 -->, <!-- ELSE --><span class="genmed">{L_SUBFORUMS}: <!-- ENDIF -->{catrow.forumrow.sub.LAST_POST_SUB} <a href="{catrow.forumrow.sub.U_VIEWFORUM}" <!-- IF catrow.forumrow.sub.UNREAD -->class="topic-new"<!-- ENDIF --> title="{catrow.forumrow.sub.FORUM_DESC_HTML}">{catrow.forumrow.sub.FORUM_NAME}</a><!-- END sub -->
    <!-- IF $HAS_SUB --></span><!-- UNDEFINE $HAS_SUB --><!-- ENDIF -->
        </td></tr></table>
  </td>
  <td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.TOTAL_TOPICS}</span></td>
  <td class="row2" align="center" valign="middle" height="50"><span class="gensmall">{catrow.forumrow.TOTAL_POSTS}</span></td>


  <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{catrow.forumrow.LAST_POST}</span></td>
If I read your situation right, this should do it. These are lines 33 through 47 in my file.

Oh, and back up your stuff before you start ;)
Also, if you are using the Extreme Styles mod, remove the php files in the cache directory or your changes just won't appear at all.

Viper07
Registered User
Posts: 85
Joined: Mon Jan 16, 2006 8:34 pm

Post by Viper07 » Sat Apr 29, 2006 7:47 pm

Thanks. Just before I try it, what template are you using?

User avatar
Freitag
Registered User
Posts: 143
Joined: Mon Jul 11, 2005 10:17 pm

Post by Freitag » Sat Apr 29, 2006 9:02 pm

That was subSilver

Markstar
Registered User
Posts: 72
Joined: Mon May 01, 2006 6:26 pm

Post by Markstar » Tue May 02, 2006 3:56 pm

Hi!
I was wondering if it is possible to also get this working for the forum categories as well. :?:

Thanks in advance!

ycl6
Translator
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 » Tue May 02, 2006 11:52 pm

You want category icon?

~Mac

Markstar
Registered User
Posts: 72
Joined: Mon May 01, 2006 6:26 pm

Post by Markstar » Wed May 03, 2006 8:16 am

ycl6 wrote: You want category icon?

Yes (for indication which language this part of the forum is).

I'm new to this so I have tried two approaches:
- my first thought was to simply modify this part of the index_body.tpl:

Code: Select all

  <tr> 
	<td class="catLeft" colspan="2" height="28" valign="middle"><span class="cattitle"><img src="../../../img/flage.jpg" /><a href="{catrow.U_VIEWCAT}" class="cattitle">{catrow.CAT_DESC}</a></span></td>
	<td class="rowpic" colspan="3" align="right">&nbsp;</td>
  </tr>
Here you see that I added the location of an image. Of course that does not work since now the image is the same for all categories. :(
Then I thought since I know I would just have two categories (or could probably easily adjust the code when I would add more categories), I could just replace the image name with a variable, like {cat_icon}, but sadly I don't know how and where I am supposed to implement the if-clause that checks for the {catrow.CAT_DESC} (yes, I read the template tutorial but must admit that I didn't quite get all of it). :cry:
As I've said, I'm new to phpBB and fairly new to PHP as well. :oops:

- my second approach was to take this mod and modify it so that the same could be done for the forum categories. However, I quickly came to the point where I would not know how to do this anymore. My impression is that this shouldn't be too difficult for someone who knows what he is doing but sadly I'm not one of them.

I would really appreciate one solution/hint on this!!!

ycl6
Translator
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 » Wed May 03, 2006 12:14 pm

It is pretty easy to modify this MOD to allow category icon. You may wait for a couple of days before I come up with something.

~Mac

Markstar
Registered User
Posts: 72
Joined: Mon May 01, 2006 6:26 pm

Post by Markstar » Thu May 04, 2006 6:44 am

ycl6 wrote: It is pretty easy to modify this MOD to allow category icon. You may wait for a couple of days before I come up with something.

Sounds great! :D

I must admit I'm also looking into antother MOD right now (Categories Hierarchy) and that one also has images for the forums (but I stumbled upon it when I was looking for a way to implement sub-forums after I posted here). In the CH MOD you can actually assign an image to the categorie in the ACP (because there is an option to transform any category to a forum and vice versa), but sadly it does not work with the categories (actually it does work in the preview in the ACP but not in the real forum). :cry:

ycl6
Translator
Posts: 5696
Joined: Sat Feb 15, 2003 10:35 am
Location: Taiwan
Contact:

Post by ycl6 » Thu May 04, 2006 9:35 am

OK, just wanna make it clear now, this MOD does not work with any sub-forum MOD, and I don't have the intention to make this work with them too (it takes too much of my time).

If you really like to use sub-forum feature, you may approach those authors to implement some kind of forum/category icon in their MODs. It would be easier that way.

~Mac

Post Reply

Return to “[2.0.x] MOD Database Releases”