Use custom header image for every thread

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
Locked
icycalm
Registered User
Posts: 9
Joined: Mon Oct 24, 2011 1:29 pm

Use custom header image for every thread

Post by icycalm » Mon Oct 24, 2011 2:58 pm

I've done extensive searches on this, but either nothing of the sort has been developed, or the term "header" that I am using for my searches is confused with phpbb's header.php files and throws the search engines off track.

The following screenshot of my forum should help explain what I am looking for:

Image

I want to be able to specify a different banner image at the top for every thread. (The way I inserted that image there is by editing my style's overall_header.html file.)

Any ideas on whether some existing mod can help with this, or whether I could implement this somehow on my own?

User avatar
Sniper_E
Registered User
Posts: 790
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Use custom header image for every thread

Post by Sniper_E » Mon Oct 24, 2011 5:01 pm

I have heard of using a different image for each category or for each forum, but to use a different image for each thread could come out to needing a thousand images. Is there a place online that has all of these images or will you need to save an image for each thread on your site?

Here is a topic on a different image for each category.
http://www.phpbb.com/community/viewtopi ... #p13029218
You could do something like that for each thread if the thread title matched the image name you wanted to show in the header.
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:

icycalm
Registered User
Posts: 9
Joined: Mon Oct 24, 2011 1:29 pm

Re: Use custom header image for every thread

Post by icycalm » Mon Oct 24, 2011 9:31 pm

It's a videogame forum, and each thread corresponds to a specific videogame. So I would like the image at the top to match the game under discussion. I will make all those images just as I made the default one: using promotional illustrations for each game, and then hosting them on my site. I am not going to be making thousands of them in one go; I will be using the default one for all threads, and then slowly making five or ten thread-specific ones every week or so. I took a look at the link you provided, and it seems to me that perhaps it could be adapted for my purposes, but I am not sure exactly how. I would even be willing to continually edit the relevant file whenever I add new images. Do you think something like this would be possible?

User avatar
Sniper_E
Registered User
Posts: 790
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Use custom header image for every thread

Post by Sniper_E » Wed Oct 26, 2011 3:45 am

Sure it would be possible.

You could make a directory ./images/topicimages/ and put all of your images in that directory.
Name that directory what you would like it to be. topicimages for this example.

In your viewtopic_body.html template the topic title is {TOPIC_TITLE}
So this is what you would use to call for each image in the header.

I'm not sure how you code in the image for the header image so...
Let's say you use <img src="images/topicimages/{TOPIC_TITLE}.gif" alt="" />

If your topic is called Guild Wars then you would put a "Guild Wars.gif" image in that directory.
Each image will have to be named exactly as the topic title is stated.
Capital letter, spaces and all... It will have to match the name.

And you will need an IF statement where you put that image tag...
IF there is not an image created yet you will need a default.gif image to show.

<!-- IF images/topicimages/{TOPIC_TITLE}.gif --><img src="images/topicimages/{TOPIC_TITLE}.gif" alt="" /><!-- ELSE --> <img src="images/topicimages/default.gif" alt="" /><!-- ENDIF -->

See if that will get you started...

And hey, we will have to work on that IF statement so it will check to see IF that image exists. The IF statement above is just an example. And also, you are not always going to be in the viewtopic page. You may need a few IF SCRIPT_NAME statements for it to act differently in the viewforum, index, search, ucp, etc...
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:

icycalm
Registered User
Posts: 9
Joined: Mon Oct 24, 2011 1:29 pm

Re: Use custom header image for every thread

Post by icycalm » Wed Oct 26, 2011 11:08 am

That sounds like a simple, elegant solution, but there seems to be some error in the code. This is what I tried:

Code: Select all

<!-- IF /phpbb/images/headers/{TOPIC_TITLE}.png --><img src="/phpbb/images/headers/{TOPIC_TITLE}.png" alt="{TOPIC_TITLE}" /><!-- ELSE --> <img src="/phpbb/images/headers/default.png" alt="default header" /><!-- ENDIF -->
Then I purged the cache, reloaded the forum index, and got a blank page with this message:

Code: Select all

Parse error: syntax error, unexpected '/' in /phpbb/cache/tpl_nebulae_overall_header.html.php on line 607
Any ideas on what went wrong? Or is the code you gave above just an example, as you say, and not ready to be tried out at all? I am an absolute beginner in this sort of thing, as you can doubtless tell.

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: Use custom header image for every thread

Post by 4_seven » Wed Oct 26, 2011 2:10 pm

To prevent a break of some pic, bcs. of eg. special chars in topic-title, it works more safe with topic-id

Code: Select all

<!-- IF TOPIC_ID == 12 --><img src="images/topicimages/12.gif" alt="" /><!-- ELSE --><img src="images/topicimages/default.gif" alt="" /><!-- ENDIF -->
but a good base idea, to make it simple as it can be. congrats :)
icycalm wrote:

Code: Select all

Parse error: syntax error, unexpected '/' in /phpbb/cache/tpl_nebulae_overall_header.html.php on line 607
this error comes, bcs. it gives no IF-syntax like

Code: Select all

<!-- IF /phpbb/images/headers/{TOPIC_TITLE}.png -->
also the presence of a pic cant be check with html
Current Mods | Mod Base | php(BB) programming | No help via PM

User avatar
Sniper_E
Registered User
Posts: 790
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Use custom header image for every thread

Post by Sniper_E » Wed Oct 26, 2011 9:23 pm

Yes, I told you above that IF statement above was not valid. It was just an example.

Excellent 4_seven, that is a much better idea using TOPIC_ID

Let's think about this. If he has a hundred topics he will have to have a hundred IF statements.
He needs a script to check to see IF exists images/headers/{TOPIC_ID}.png
Then he could use <img src="images/headers/{TOPIC_ID}.png" alt="" />

http://php.net/manual/en/function.file-exists.php
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:

User avatar
doktornotor
Registered User
Posts: 608
Joined: Fri Sep 09, 2011 7:41 am

Re: Use custom header image for every thread

Post by doktornotor » Wed Oct 26, 2011 9:58 pm

Folks, would not one of those "first X pics in topic" mods make a whole lot more sense to start with? Just attach it to the first post in topic and get it displayed in header. Zillions of IF statements does not sound like fun, and neither does manually managing the pics.
Support requests via PM go straight to /dev/null!

User avatar
trigger_error
I've Been Banned!
Posts: 200
Joined: Mon Feb 21, 2011 1:27 pm

Re: Use custom header image for every thread

Post by trigger_error » Wed Oct 26, 2011 11:38 pm

jap, good intention. may i create a very simple version to realize that without board overload. just put the image in first post and all is fine.

User avatar
Sniper_E
Registered User
Posts: 790
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Use custom header image for every thread

Post by Sniper_E » Thu Oct 27, 2011 7:35 am

First Topic [pic] on Forum Index - just clarifying...

Can this mod be altered to show in the viewtopic instead of in the index?
And can it be altered to grab the first image in the topic he is in?

He wants the first image in that topic to be the header image when he is in that topic.
When he is in a different topic he wants the first image in that topic to be in the header.
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:

icycalm
Registered User
Posts: 9
Joined: Mon Oct 24, 2011 1:29 pm

Re: Use custom header image for every thread

Post by icycalm » Fri Oct 28, 2011 1:22 pm

I am currently using 4_seven's code, and it works fine, so I am happy with that. It's true that adding all those IF statements is not fun, but I get the result that I wanted, so the job's done and all's well. If, however, I could get Sniper's suggestion to work, so that I wouldn't need to include a thousand IF statements (and aren't they going to slow down my forum by bloating the header_overall.html file too much?) I would of course be even happier. So if Sniper or someone else can provide me with the exact code to use, I'll try it out and report back with the results. In the meantime I'll keep using what I've got.

As for the suggestion to use a mod that picks the first image in each thread and turns it into a header, it goes against what I am trying to achieve. I am trying to achieve a beautiful forum. Having the very same 960x335 image twice at the top of each thread is ugly, I am afraid...

So thanks for everyone's help so far, and I am looking forward to try any more refined suggestions you may have.

User avatar
doktornotor
Registered User
Posts: 608
Joined: Fri Sep 09, 2011 7:41 am

Re: Use custom header image for every thread

Post by doktornotor » Fri Oct 28, 2011 2:28 pm

icycalm wrote: As for the suggestion to use a mod that picks the first image in each thread and turns it into a header, it goes against what I am trying to achieve. I am trying to achieve a beautiful forum. Having the very same 960x335 image twice at the top of each thread is ugly, I am afraid...
Not exactly what I meant to be done.

1/ Mod it so that the image attachments in the first post of the topic do NOT get inlined in the post
2/ Get them displayed in the header instead.

Is this what would fit your needs?
Support requests via PM go straight to /dev/null!

icycalm
Registered User
Posts: 9
Joined: Mon Oct 24, 2011 1:29 pm

Re: Use custom header image for every thread

Post by icycalm » Fri Oct 28, 2011 8:33 pm

Yes, that would do it, if by "header" you mean the overall_header.html file.

User avatar
Sniper_E
Registered User
Posts: 790
Joined: Wed May 09, 2007 12:18 am
Location: Shreveport, Louisiana
Name: Ed Humphrey
Contact:

Re: Use custom header image for every thread

Post by Sniper_E » Sun Oct 30, 2011 3:57 am

Here is another thought of what might work perfect for this...
Isn't there a topic description mod out there somewhere?
I've seen it somewhere.

You can make a header image for a topic.and put it in that directory you made for them.
Then in the header where you have the image, use
<!-- IF TOPIC_DESCRIPTION --><img scr="images/headers/{SITE_DESCRIPTION}.png" alt="" /><!-- ELSE -->{SITE_LOGO_IMG}<!-- ENDIF -->

After you get that working... every time you create a.new image for any topic, you go in that topic and fill in the topic description with the name of the image you saved.

Did that make since?
Never mind, I just looked and it wasn't site description I saw. As you were...
Image
No is NEVER an Option and NEVER is the only Option when it comes to Giving Up!
:!: Sniper_E Styles | phpbbmodders :!:

Locked

Return to “[3.0.x] MOD Requests”