Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Topic started by: dougiefresh on November 29, 2017, 05:04:09 PM

Title: Replace Board Title With Image
Post by: dougiefresh on November 29, 2017, 05:04:09 PM
Link to Mod (https://custom.simplemachines.org/mods/index.php?mod=4162)



REPLACE BOARD TITLE WITH IMAGE v1.4
By Dougiefresh (http://www.simplemachines.org/community/index.php?action=profile;u=253913) -> Link to Mod (http://custom.simplemachines.org/mods/index.php?mod=4162)



Introduction
The idea for this mod came from a topic titled A Neat Way To Enhance A Board! (https://www.simplemachines.org/community/index.php?topic=547240.msg3882384#msg3882384), which wrote about a way to use an image in place of the board title.  This mod attempts to accomplish this objective with a minimum of changes to the forum software.

Please note that at this time, there is no automated way to upload images to the server.  You must upload them to a location underneath the forum folder and refer to them as relative paths.  In other words, if you upload it to /forum/Themes/default/images/duh.png, then you would type Themes/default/images/duh.png into the board image field.

Admin Settings
In Admin => Forum => Boards, there is a new field when modifying the boards:
o Replacement Board Title image

Compatibility Notes
This mod was tested on SMF 2.0.14 and SMF 2.1 Beta 3, but should work on SMF 2.0 and up.  SMF 1.x is not and will not be supported.

This mod does not require the SVG As Image Attachment (http://custom.simplemachines.org/mods/index.php?mod=4085) mod to be installed prior or after this mod.  Rather, if the mod has been installed, it will try to use the functions from that mod (as opposed to the built-in getimagesize function).

Related Discussions
o A Neat Way To Enhance A Board! (https://www.simplemachines.org/community/index.php?topic=547240.msg3882384#msg3882384)
o Will it wreak havoc to use an image here? (https://www.simplemachines.org/community/index.php?topic=547224.msg3882203#msg3882203)

Changelog
The changelog can be viewed at XPtsp.com (http://www.xptsp.com/board/free-modifications/replace-board-title-with-image/?tab=1).

License
Copyright (c) 2017 - 2018, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Title: Re: Replace Board Title With Image
Post by: -Rock Lee- on November 29, 2017, 09:42:33 PM
The idea seems very good but it resonates to me. What happens when you have many forums would not cause a problem when loading the images? I also leave the translation in Spanish :P


Regards!
Title: Re: Replace Board Title With Image
Post by: dougiefresh on November 29, 2017, 11:52:20 PM
Uploaded v1.1 - November 29th, 2017
o Added support for SMF 2.1 Beta 3.
o Added support for the SVG As Image Attachment (http://custom.simplemachines.org/mods/index.php?mod=4085) mod.
o Added Spanish Latin translation, courtsey of Rock Lee (https://www.simplemachines.org/community/index.php?action=profile;u=322597)!
o Added file exists check so that missing images won't cause boards to become inaccessable.





@Rock Lee:  Thank you for the translation!  It's been included in this version!

Quote from: Rock Lee on November 29, 2017, 09:42:33 PM
What happens when you have many forums would not cause a problem when loading the images?
I've read both discussions that I've linked to in the first post.  I can't foresee any issues that might arise from using this mod....  If you run into any problems running this mod, please share them with me so that I can try to fix the issue....
Title: Re: Replace Board Title With Image
Post by: -Rock Lee- on November 30, 2017, 07:32:07 AM
Quote from: dougiefresh on November 29, 2017, 11:52:20 PM
I've read both discussions that I've linked to in the first post.  I can't foresee any issues that might arise from using this mod....  If you run into any problems running this mod, please share them with me so that I can try to fix the issue....

Great @dougiefresh will be testing to what this or that problem :P


Regards!
Title: Re: Replace Board Title With Image
Post by: Aleksi "Lex" Kilpinen on December 29, 2017, 08:09:53 AM
Tested this out with a fresh 2.1 beta 3

PHP message:
PHP Parse error: syntax error, unexpected ',', expecting ')' in /Sources/Subs-Boards.php on line 1329

Also, the reason I wanted to test was, to see if this bit actually works:


if (file_exists($sourcedir . '/Subs-SVG.php'))
$img_dim = @getimagesize($boarddir . '/' . $boardOptions['board_image']);
else
$img_dim = @svg_getimagesize($boarddir . '/' . $boardOptions['board_image']);


In my mind, that's backwards. Is it not?
Title: Re: Replace Board Title With Image
Post by: dougiefresh on December 29, 2017, 10:23:31 PM
Uploaded v1.2 - December 29th, 2017
o Fixed coding error that fails to properly get image sizes.
o SMF 2.1: Fixed syntax error in Sources/Subs-Boards.php.




@Aleksi "Lex" Kilpinen:  Thank you for reporting this bug!  It's been fixed in this version!
Title: Re: Replace Board Title With Image
Post by: Aleksi "Lex" Kilpinen on December 30, 2017, 02:38:28 AM
You are welcome :)
Title: Re: Replace Board Title With Image
Post by: pepa on December 31, 2017, 06:54:34 AM
Tried installing this and received the warning message not to proceed unless you really know what you are doing ... so obviously some incompatibilities somewhere?

SMF 2.0.14
Mods: Board-color-and-icons 1.1, reCAPTCHA for SMF 1.0.0, Responsive Curve 1.0.0, PayPal Donate 1.0, Global Topics 2.2
Title: Re: Replace Board Title With Image
Post by: dougiefresh on December 31, 2017, 07:21:17 AM
I'll take a look and see what I can do about the incompatibility/incompatibilities...
Title: Re: Replace Board Title With Image
Post by: dougiefresh on January 02, 2018, 12:59:33 PM
Uploaded v1.3 - January 2nd, 2018
o Resolved incompatability with Board color and icons (https://custom.simplemachines.org/mods/index.php?mod=3023) mod.




@pepa:  Thank you for the report!  Hopefully, this solves this issue you were experiencing!
Title: Re: Replace Board Title With Image
Post by: pepa on January 03, 2018, 08:01:57 AM
Yes thank you dougiefresh, that did the trick : )
Title: Re: Replace Board Title With Image
Post by: dougiefresh on October 25, 2018, 08:05:33 PM
Uploaded v1.4 - October 23rd, 2018
o No functionality change.
o Updated documentation to point to new website.
Title: Re: Replace Board Title With Image
Post by: landyvlad on January 20, 2019, 10:26:12 PM
Can I suggest some 'before and after' images as examples on the mod page so people can see what it actually can look like?
Title: Re: Replace Board Title With Image
Post by: shadav on August 24, 2019, 05:45:52 PM
I installed this on 2.0.15
it works but.... it doesn't size with the image size
each image is 300 x 200 px
so shouldn't the boards all be the same spacing? why are some more and others less and one is really bad :p

thank you for this though :) but how can I fix this?

well removing the images and then adding them again seemed to have fixed this... so it's ok now :) not sure what happened.....
Title: Re: Replace Board Title With Image
Post by: shadav on August 02, 2020, 12:32:06 AM
just noticed today that it doesn't work on child boards....

the image is fine, as I use it for another board

but this is the first time I'm trying to use it on a child board

how to fix this? it acts like it's wanting to work but the image isn't there....

[edit] forgot to say it's for a 2.0.17 :) thank you
Title: Re: Replace Board Title With Image
Post by: shadav on August 11, 2020, 10:59:44 PM
Quote from: shadav on August 02, 2020, 12:32:06 AM
just noticed today that it doesn't work on child boards....

the image is fine, as I use it for another board

but this is the first time I'm trying to use it on a child board

how to fix this? it acts like it's wanting to work but the image isn't there....

[edit] forgot to say it's for a 2.0.17 :) thank you

figured it out

normally I'd just type in
foldername/filename

but for subcategories you have to type in
/foldername/filename

for it to work correctly
otherwise it's trying to pull the image from url/subcategory/foldername/filename, which obviously doesn't exist....
Title: Re: Replace Board Title With Image
Post by: lather on January 23, 2021, 03:21:54 PM
I successfully installed this mod on my 2.0.15 forum but am  have not been able to make it work. I have uploaded a test image to Themes/default/images and enter that url but nothing happens. No error message but nothing changes on the board.
Title: Re: Replace Board Title With Image
Post by: sam666 on January 24, 2021, 06:19:35 PM
If it's any help, here is the url I put for one of my boards which works fine.
/Themes/default/images/android.png
image size used is 32x32
Title: Re: Replace Board Title With Image
Post by: lather on January 25, 2021, 09:32:46 AM
Quote from: stoneageman on January 24, 2021, 06:19:35 PM
If it's any help, here is the url I put for one of my boards which works fine.
/Themes/default/images/android.png
image size used is 32x32
Thanks for the reply. That is exactly the url I used (ecept for image nmae). I used a much larger image. Will try with a smaller one.

Nope that did not help!
Title: Re: Replace Board Title With Image
Post by: shadav on January 25, 2021, 10:53:18 AM
Quote from: lather on January 23, 2021, 03:21:54 PM
I successfully installed this mod on my 2.0.15 forum but am  have not been able to make it work. I have uploaded a test image to Themes/default/images and enter that url but nothing happens. No error message but nothing changes on the board.
When you installed the mod was there any errors on the install page?
are you using a custom theme? if you switch to default theme does it work?
this shouldn't really be an issue with this mod but can't hurt....

make sure that the image was uploaded....go to the images url and make sure that it is there and viewable....

are you using cache? clear your cache then reload the page.....clear your browsers cache and reload the page....

use the parse on the mod page and make sure that all edits were made
Title: Re: Replace Board Title With Image
Post by: lather on January 25, 2021, 11:22:26 AM
Quote from: shadav on January 25, 2021, 10:53:18 AM
Quote from: lather on January 23, 2021, 03:21:54 PM
I successfully installed this mod on my 2.0.15 forum but am  have not been able to make it work. I have uploaded a test image to Themes/default/images and enter that url but nothing happens. No error message but nothing changes on the board.
When you installed the mod was there any errors on the install page?
are you using a custom theme? if you switch to default theme does it work?
this shouldn't really be an issue with this mod but can't hurt....

make sure that the image was uploaded....go to the images url and make sure that it is there and viewable....
are you using cache? clear your cache then reload the page.....clear your browsers cache and reload the page....

use the parse on the mod page and make sure that all edits were made
Thanks for your reply. There were no errors on install of the mod. The current theme is SMF Default Theme - Curve
I uploaded the image with ftp to /public_html/mstaforums/Themes/default/images and can view it with FTP client.
I have not cleared caches I will try that.  I will also check the edits. Thanks again.
Title: Re: Replace Board Title With Image
Post by: lather on January 25, 2021, 02:09:16 PM
I have cleared caches fro the forum and my browser, no luck.
I verified the edits to all these files:
./Themes/default/ManageBoards.template.php
./Themes/default/languages/ManageBoards.english.php
/Sources/Subs-Boards.php
./Sources/Subs-BoardIndex.php
./Sources/ManageBoards.php
The only missing is
ManageBoards.spanish_latin.php we do noy have that file but should not make any difference

I looked at the SMF_boards table in the database and the  3 image fields are there but img _name is blank and width and height are 0

Title: Re: Replace Board Title With Image
Post by: lather on February 01, 2021, 11:17:55 AM
I still can't get this to work, I must be missing something obvious. Any more suggestions?
Title: Re: Replace Board Title With Image
Post by: shadav on February 01, 2021, 11:35:40 AM
does it replace the board title but just with a blank space or is the board title still there?
Title: Re: Replace Board Title With Image
Post by: lather on February 01, 2021, 12:18:40 PM
The board title is still there. When I return to the mod and try again the title field is blank.
In other words the path and image file name I previously enter is not there.
Title: Re: Replace Board Title With Image
Post by: Tonyvic on February 01, 2021, 01:44:00 PM
You are scrolling down and selecting the 'Modify' button after entering the url?
Title: Re: Replace Board Title With Image
Post by: lather on February 01, 2021, 01:56:43 PM
Yes.
Title: Re: Replace Board Title With Image
Post by: shadav on February 01, 2021, 03:25:50 PM
did you use the package manager to install this mod or did you manually install it?
if manually, did you upload the file db_install.php to your site and the run it by going to yoursite url/db_install.php
Title: Re: Replace Board Title With Image
Post by: lather on February 01, 2021, 04:06:11 PM
I did use the package Manager..
Title: Re: Replace Board Title With Image
Post by: shadav on February 01, 2021, 04:17:41 PM
if you want to pm me the url, access to ftp and an admin account
I'll try to take a look and see if I can find anything....
Title: Re: Replace Board Title With Image
Post by: lather on February 01, 2021, 04:34:53 PM
Thank you for that kind offer. I will need to get our club president approval.
Title: Re: Replace Board Title With Image
Post by: lather on February 02, 2021, 09:24:18 AM
I finally got the mod to work. :) I had been  selecting default theme since when I look at current theme in admin is shows: SMF Default Theme - Curve
This time I tried "core" and it worked. Thanks again for all your help.
Title: Re: Replace Board Title With Image
Post by: shadav on February 02, 2021, 02:53:54 PM
not sure I understand, you uploaded the file to the core theme instead of the default theme?

Anyways glad you got it sorted it :)

what I did was created a new folder in the main forum's folder (where the Settings.php file is)
I'm lazy at names so I just named this new folder, replaceboardname
that way the images aren't theme dependent
and then just call the image as
/replaceboardname/IMAGENAME.EXTENTION
Title: Re: Replace Board Title With Image
Post by: lather on February 02, 2021, 07:08:53 PM
Quote from: shadav on February 02, 2021, 02:53:54 PM
not sure I understand, you uploaded the file to the core theme instead of the default theme?

Anyways glad you got it sorted it :)

what I did was created a new folder in the main forum's folder (where the Settings.php file is)
I'm lazy at names so I just named this new folder, replaceboardname
that way the images aren't theme dependent
and then just call the image as
/replaceboardname/IMAGENAME.EXTENTION
This is what about drove me crazy (admittedly a short trip) To get it to work the image had to be in /public_html/mstaforums/Themes/default/images but when modifying the board I had to select core theme from the pull down. I think the previous admin who set up the forum messed up our themes some way, I don't know... see attachment.  Anyway your solution sounds much better, thanks!
Title: Re: Replace Board Title With Image
Post by: shadav on February 02, 2021, 07:22:10 PM
yeah that's not right....something some where's off

also don't forget to add the / in front
if you try to use it in a sub board it won't work unless you put the / before
/Themes/default/images/IMAGENAME

otherwise it tries to pull the image from forum/sub-board/themes/default/images/IMAGENAME
Title: Re: Replace Board Title With Image
Post by: Dave J on February 13, 2022, 07:32:04 AM
Is there any chance of this being updated to SMF2.1.1 please?
Title: Re: Replace Board Title With Image
Post by: lather on February 16, 2022, 08:20:10 PM
Please.
Title: Re: Replace Board Title With Image
Post by: Grammy on August 08, 2022, 09:27:25 PM
I got this to work in 2.1.2 by manually installing it, after seeing that it failed emulation.

In Sources/Subs-BoardIndex.php, I had to find
        'b.name AS board_name',
        'b.description',
  and add after
        'b.img_name',
        'b.img_width',
        'b.img_height',

and in Sources/Subs-Boards.php I had to find
global $cat_tree, $boards, $smcFunc  and add after
, $boarddir, $sourcedir,
(I had to add $sourcedir, because otherwise, it threw an Unknown Variable: $sourcedir error for that file.)

All the other file edits in the manual installation for 2.1 were fine, only Sources/Subs-BoardIndex.php and Sources/Subs-Boards.php were problematic.  (And I had to remember to add the language file edits.)

The db_install.php file worked with no issue and the image appears just as it should, with no log errors...  for me, anyway.

(I'm only posting this because someone asked and since I kick tires and test things, I tried it and it works fine, no errors, and the images appears as it should. 

O:)
Title: Re: Replace Board Title With Image
Post by: Grammy on August 09, 2022, 12:13:08 PM
Well....  okay, all good except for an error I didn't discover until I tried to create a new board: 
Undefined index: image
That's coming from ManageBoards.template.php, line 347:
   
<input type="text" name="board_image" value="', $context['board']['image']['name'], '" size="30" class="input_text" />

Does this require an "isset" statement?  (Like I even know what I'm asking...)  :-\


 :D
Title: Re: Replace Board Title With Image
Post by: Grammy on August 09, 2022, 01:12:16 PM
Quote from: Grammy on August 09, 2022, 12:13:08 PMWell....  okay, all good except for an error I didn't discover until I tried to create a new board: 
Undefined index: image
That's coming from ManageBoards.template.php, line 347:
   
<input type="text" name="board_image" value="', $context['board']['image']['name'], '" size="30" class="input_text" />

Does this require an "isset" statement?  (Like I even know what I'm asking...)  :-\


 :D

Never mind, I sorted it. 

   
<input type="text" name="board_image" value="', $context['board']['image']['name'], '" size="30" class="input_text" />

is now this:

    <input type="text" name="board_image" value="' . $verify_context = &$context['board']['image']['name'], '" size="30" class="input_text" />
An old SMF friend of mine used to call this "Duct Tape".  :D

Title: Re: Replace Board Title With Image
Post by: Dave J on August 18, 2022, 08:58:26 AM
Thanks but I had a problem with it, so I'd still like a correct version that will install from the Package manager please
Title: Re: Replace Board Title With Image
Post by: Doug Heffernan on August 18, 2022, 09:02:08 AM
Quote from: Dave J on August 18, 2022, 08:58:26 AMThanks but I had a problem with it, so I'd still like a correct version that will install from the Package manager please

By the looks of it the mod author has not been active for quite some time. Their last post was 3 years ago.
Title: Re: Replace Board Title With Image
Post by: Dave J on August 18, 2022, 09:29:14 AM
Quote from: Doug Heffernan on August 18, 2022, 09:02:08 AM
Quote from: Dave J on August 18, 2022, 08:58:26 AMThanks but I had a problem with it, so I'd still like a correct version that will install from the Package manager please

By the looks of it the mod author has not been active for quite some time. Their last post was 3 years ago.

We can but ask Doug  ;)
Title: Re: Replace Board Title With Image
Post by: Grammy on August 18, 2022, 09:35:07 AM
Quote from: Dave J on August 18, 2022, 08:58:26 AMThanks but I had a problem with it, so I'd still like a correct version that will install from the Package manager please

Mine is working really well now, 2.1.2, default, but I did have to go in and make that 2nd edit I mentioned on page 2.  (But I don't have any other mods, so that may be why I'm in the clear.)   :)
Title: Re: Replace Board Title With Image
Post by: Dave J on August 18, 2022, 09:46:48 AM
Quote from: Grammy on August 18, 2022, 09:35:07 AM
Quote from: Dave J on August 18, 2022, 08:58:26 AMThanks but I had a problem with it, so I'd still like a correct version that will install from the Package manager please

Mine is working really well now, 2.1.2, default, but I did have to go in and make that 2nd edit I mentioned on page 2.  (But I don't have any other mods, so that may be why I'm in the clear.)   :)

Yes I have 18 mods installed and as you say this might be the issue