Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: TheCore in August 15, 2009, 08:27:06 NACHMITTAGS

Titel: Logo with link to (any) homepage
Beitrag von: TheCore in August 15, 2009, 08:27:06 NACHMITTAGS
When the Forum is part of another Homepage, some of us like to incorporate a link back to the Homepage.
The solutions I found was rather complex and involved some mods. I like faster and more dirty
solutions, like this one, making that linked logo available anywhere in the Forum tree.
I assume you know as good as nothing, so I add some details you may skip if you know your
way around.

Most have the Forum installed as a subdomain of MYSite.com (like: forum.MYSite.com)
You'll figure that out I guess. It's normal to have the directory "Forum" (or what you call it) in
your public_html directory, or folder as the Mac'ers call it - where your Homepage content is.

First, upload your logo to the Theme images folder.
It's located something like this: MYSite.com/Forum//Themes/MYTheme/images/MYLogo.jpg

Next, login as forum Admin and add your logo to the Header.
You do this in: Configuration>Current Theme>Themes and Settings by adding
the path into the Logo image URL field like this:
forum.MYSite.com/Themes/MYTheme/images/MYLogo.jpg
If you see the logo in the head after "Save" you are close to genius. IQ rules. (luck too).

Now we add a link to that logo so users can jump from
forum.MYSite.com to your Homepage MYSite.com
with a click on the logo.

Do this:
On that same setup page: (Configuration>Current Theme>Themes and Settings),
at the top is a link saying: Modify the index template. (the main template).
Stare at it - and then Click on it. The Edit Theme - index.template.php page show up.
Scroll down to the code field named: Beginning on line 59.. Your almost there...
Scroll that field to approx middle. You are looking for this little line of code:


else
echo '<img src="', $settings['header_logo_url'], '" style="margin: 4px;" alt="', $context['forum_name'], '" />';


Change this code to:
else
echo '<a href="http://www.MYSite.com"><img src="', $settings['header_logo_url'], '" style="margin: 4px;" alt="', $context['forum_name'], '" /></a>';


..and don't forget that </a> at the end of that code. You are only adding the link. DON'T modify anything else. That's it, click save and look smart!  8)

TheCore
Titel: Re: Logo with link to (any) homepage
Beitrag von: babjusi in August 22, 2009, 02:51:08 NACHMITTAGS
There is already a mod for this.

http://custom.simplemachines.org/mods/index.php?mod=1381
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 05, 2018, 10:55:50 VORMITTAG
Zitat von: TheCore in August 15, 2009, 08:27:06 NACHMITTAGS
When the Forum is part of another Homepage, some of us like to incorporate a link back to the Homepage.
The solutions I found was rather complex and involved some mods. I like faster and more dirty
solutions, like this one, making that linked logo available anywhere in the Forum tree.
I assume you know as good as nothing, so I add some details you may skip if you know your
way around.

Most have the Forum installed as a subdomain of MYSite.com (like: forum.MYSite.com)
You'll figure that out I guess. It's normal to have the directory "Forum" (or what you call it) in
your public_html directory, or folder as the Mac'ers call it - where your Homepage content is.

First, upload your logo to the Theme images folder.
It's located something like this: MYSite.com/Forum//Themes/MYTheme/images/MYLogo.jpg

Next, login as forum Admin and add your logo to the Header.
You do this in: Configuration>Current Theme>Themes and Settings by adding
the path into the Logo image URL field like this:
forum.MYSite.com/Themes/MYTheme/images/MYLogo.jpg
If you see the logo in the head after "Save" you are close to genius. IQ rules. (luck too).

Now we add a link to that logo so users can jump from
forum.MYSite.com to your Homepage MYSite.com
with a click on the logo.

Do this:
On that same setup page: (Configuration>Current Theme>Themes and Settings),
at the top is a link saying: Modify the index template. (the main template).
Stare at it - and then Click on it. The Edit Theme - index.template.php page show up.
Scroll down to the code field named: Beginning on line 59.. Your almost there...
Scroll that field to approx middle. You are looking for this little line of code:


else
echo '<img src="', $settings['header_logo_url'], '" style="margin: 4px;" alt="', $context['forum_name'], '" />';


Change this code to:
else
echo '<a href="http://www.MYSite.com"><img src="', $settings['header_logo_url'], '" style="margin: 4px;" alt="', $context['forum_name'], '" /></a>';


..and don't forget that </a> at the end of that code. You are only adding the link. DON'T modify anything else. That's it, click save and look smart!  8)

TheCore

This solution for adding a URL link to the forum logo is rather old and seems to require editing a file.  I have our own logo image loaded, but is there no other way to add a URL link to the logo image?
Titel: Re: Logo with link to (any) homepage
Beitrag von: Kindred in Juni 05, 2018, 12:31:18 NACHMITTAGS
no. The only way to CHANGE the URL that the logo points to is to edit the code in index.template.php -- unless your theme allows a defined URL (some might, the default theme does not)


although, it looks like the mod posted just before your post may actually work in 2.0.x as well as 1.1.x (you would have to use the emulate version feature, to get the installation option)
Titel: Re: Logo with link to (any) homepage
Beitrag von: GigaWatt in Juni 05, 2018, 12:38:35 NACHMITTAGS
Zitat von: Kindred in Juni 05, 2018, 12:31:18 NACHMITTAGS
although, it looks like the mod posted just before your post may actually work in 2.0.x as well as 1.1.x (you would have to use the emulate version feature, to get the installation option)

Titel: Re: Logo with link to (any) homepage
Beitrag von: Aleksi "Lex" Kilpinen in Juni 05, 2018, 01:03:09 NACHMITTAGS
Yeah, seems it was removed from the modsite years ago - don't know why though.
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 05, 2018, 09:15:31 NACHMITTAGS
Zitat von: Kindred in Juni 05, 2018, 12:31:18 NACHMITTAGS
no. The only way to CHANGE the URL that the logo points to is to edit the code in index.template.php -- unless your theme allows a defined URL (some might, the default theme does not)


although, it looks like the mod posted just before your post may actually work in 2.0.x as well as 1.1.x (you would have to use the emulate version feature, to get the installation option)

Forgive my ignorance, but if I do edit the index.template.php file for the logo URL, do I have to re-edit it every time after future updates?
Titel: Re: Logo with link to (any) homepage
Beitrag von: Aleksi "Lex" Kilpinen in Juni 05, 2018, 11:35:35 NACHMITTAGS
No, patches will not overwrite edits like that.
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 06, 2018, 05:01:34 NACHMITTAGS
So I was going to attempt to edit the index.template.php file, but I think the line numbers have changed since the original post above.

That is, I looked for the line:

Zitatelse
echo '<img src="', $settings['header_logo_url'], '" style="margin: 4px;" alt="', $context['forum_name'], '" />';

but can't locate it.  Can someone help?
Titel: Re: Logo with link to (any) homepage
Beitrag von: skb in Juni 06, 2018, 07:09:49 NACHMITTAGS
You can do a Cntrl+F and Search for the text string. The line should be in the vicinity of the line number given.
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 06, 2018, 07:46:32 NACHMITTAGS
Zitat von: skb in Juni 06, 2018, 07:09:49 NACHMITTAGS
You can do a Cntrl+F and Search for the text string. The line should be in the vicinity of the line number given.

I can do that from the browser GUI?  Cool.
Titel: Re: Logo with link to (any) homepage
Beitrag von: Kindred in Juni 06, 2018, 09:03:11 NACHMITTAGS
Search for the header_logo_url
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 07, 2018, 02:06:11 NACHMITTAGS
So it's in the section labeled "Beginning on line 168", here:

            <a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>

But it says "header_logo_url_html_safe". Is this what gets edited?  Can you show me an example?

Sorry to bother you all, but I'm just a newbie.
Titel: Re: Logo with link to (any) homepage
Beitrag von: Kindred in Juni 07, 2018, 04:43:38 NACHMITTAGS
that URL is a setting that displays the IMAGE as defined in the theme setting in the admin
the edit you would be replacing is this


', $scripturl, '

replace that with your actual URL
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 07, 2018, 06:11:03 NACHMITTAGS
OK, so it would be:

<a href="http:\\myurl.com">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>

?

Also, by the way, it there an SMF posting setting that defaults to always "Return to this topic"?
Titel: Re: Logo with link to (any) homepage
Beitrag von: Kindred in Juni 07, 2018, 08:00:23 NACHMITTAGS
yes, that would be the correct code.

yes, in your profile setting
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 07, 2018, 08:16:19 NACHMITTAGS
That does not work.  It sets the logo link to myurl.com/myurl.com

What should I do?
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 07, 2018, 08:17:59 NACHMITTAGS
OK, I figured it out (on my own!).  It needs to be set to:

<a href="http:\\">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
Titel: Re: Logo with link to (any) homepage
Beitrag von: Kindred in Juni 07, 2018, 08:36:28 NACHMITTAGS
no, that can't be right. you need an actual url in there
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 07, 2018, 09:00:43 NACHMITTAGS
You know more than me, but I'm just glad it's working!

Our forum is here:

http://probesoftware.com/smf/index.php

I edited the index.template.php file in the SMF Default Theme (2.0.14) right?  Not the Core Theme (2.0), right?
Titel: Re: Logo with link to (any) homepage
Beitrag von: GigaWatt in Juni 08, 2018, 09:19:55 VORMITTAG
Zitat von: probeman in Juni 07, 2018, 09:00:43 NACHMITTAGS
I edited the index.template.php file in the SMF Default Theme (2.0.14) right?  Not the Core Theme (2.0), right?

Yes, that's the one that should be edited ;).

Zitat von: Kindred in Juni 07, 2018, 08:36:28 NACHMITTAGS
no, that can't be right. you need an actual url in there

Zitat von: probeman in Juni 07, 2018, 08:17:59 NACHMITTAGS
<a href="http:\\">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>

He's right, you need to have an actual URL in there, otherwise, it won't work. Have no idea how it works on your site with the "unfinished" URL.
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 08, 2018, 11:31:29 VORMITTAG
Zitat von: GigaWatt in Juni 08, 2018, 09:19:55 VORMITTAG
Zitat von: probeman in Juni 07, 2018, 09:00:43 NACHMITTAGS
I edited the index.template.php file in the SMF Default Theme (2.0.14) right?  Not the Core Theme (2.0), right?

Yes, that's the one that should be edited ;).

Why the wink emoticon?   Are you saying I edited the wrong file?   I don't enjoy this being non-standard, I prefer to get it right.

Let me set it back to the original text and walk through the steps just confirm.  I went to Themes | Themes and Layout Settings  | Modify Themes menu, Then under Modify Themes | SMF Default Theme Curve (2.0.14) I clicked the "Browse the templates and files in this theme" link.

Then I clicked on index.template.php and edited these lines back to the original text"

Zitatfunction template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo !empty($settings['forum_width']) ? '
<div id="wrapper" style="width: ' . $settings['forum_width'] . '">' : '', '
   <div id="header"><div class="frame">
      <div id="top_section">
         <h1 class="forumtitle">
            <a href="', $scripturl,'">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
         </h1>';

   // the upshrink image, right-floated
   echo '

Then I clicked Save Changes and with this original text our forum logo link points to our forum as before.  So then I replaced the above red text to this text in red:

Zitatfunction template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

   echo !empty($settings['forum_width']) ? '
<div id="wrapper" style="width: ' . $settings['forum_width'] . '">' : '', '
   <div id="header"><div class="frame">
      <div id="top_section">
         <h1 class="forumtitle">
            <a href="http://probesoftware.com">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
         </h1>';

   // the upshrink image, right-floated
   echo '

Then clicked Save Changes.  Then when I put my mouse over our logo... wait a minute, that's weird.  It works now.

Hmmm, I'm pretty dyslexic so I have to wonder if it's because I had put http:\\probesoftware.com instead of http://probesoftware.com

Weird.  I'm really sorry for all the trouble.  It's working now with the full URL so I'm happy.  Thanks and sorry again.
Titel: Re: Logo with link to (any) homepage
Beitrag von: Kindred in Juni 08, 2018, 01:13:51 NACHMITTAGS
glad its working.

incidentally.... although you CAN use the online/admin editor like that - best practice is to use your hosting file manager or FTP to edit php files
(and making bad edits directly could make your site inaccessible to correct the edit)

also, remember, with any updates, you may need to clear the cache after the change is applied...  both server side and browser side (ctrl-f5 on the page)
Titel: Re: Logo with link to (any) homepage
Beitrag von: probeman in Juni 08, 2018, 01:33:08 NACHMITTAGS
Zitat von: Kindred in Juni 08, 2018, 01:13:51 NACHMITTAGS
incidentally.... although you CAN use the online/admin editor like that - best practice is to use your hosting file manager or FTP to edit php files
(and making bad edits directly could make your site inaccessible to correct the edit)

I was wondering about that, but was also scared of ftp'ing the file back with the wrong file permissions...

Thanks for all your help.
Titel: Re: Logo with link to (any) homepage
Beitrag von: GigaWatt in Juni 08, 2018, 05:43:03 NACHMITTAGS
Zitat von: probeman in Juni 08, 2018, 11:31:29 VORMITTAG
Why the wink emoticon?   Are you saying I edited the wrong file?   I don't enjoy this being non-standard, I prefer to get it right.

It's a smiley... as far as I know ???... emoticons are symbols, smileys are formed using a combination of ASCII characters.

Beside the point... I used the wink smiley to say "you're right, that's the file that should be edited". I rarely use sarcasm in posts. If I wanted to be sarcastic, I would have written something like "Yeah, that's the one ::)".

Zitat von: probeman in Juni 08, 2018, 11:31:29 VORMITTAG
Let me set it back to the original text and walk through the steps just confirm.  I went to Themes | Themes and Layout Settings  | Modify Themes menu, Then under Modify Themes | SMF Default Theme Curve (2.0.14) I clicked the "Browse the templates and files in this theme" link.

Correct ;). (Not being sarcastic.)

As for the rest of the post (not to quote the whole thing), yes, you did the right corrections ;). In your previous post (https://www.simplemachines.org/community/index.php?topic=331170.msg3975409#msg3975409), you wrote that you only added http://, not http://probesoftware.com... in which case it wouldn't have worked. I think that's what Kindred was trying to say, it can't work with an "unfinished" URL, you have to have the full URL in that field, the way you explained it in you next post ;) (again, not being sarcastic).
Titel: Re: Logo with link to (any) homepage
Beitrag von: brenth in September 06, 2019, 08:45:04 VORMITTAG
I found this thread that described what I was trying to do with my new installation of SMF, however I seem to be having trouble making it work. I uploaded my logo image and that is displayed. I then found the header url line in the index template and edited it.

I changed this line

<a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>

to this

<a href="mysiteurl">', empty($context['header_logo_url_html_safe']) ? $context['forum_name'] : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>

But when I attempt to save it I get this error.

Template Parse Error!
There was a problem loading the /Themes/default/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.
syntax error, unexpected 'header_logo_url_html_safe' (T_STRING), expecting ',' or ';'

I have been careful not to change any other part of the template, so I do not know how to correct this error and was wondering if anyone might have a suggestion.
Titel: Re: Logo with link to (any) homepage
Beitrag von: Shambles in September 06, 2019, 09:05:02 VORMITTAG
Please download and attach that file to your next post and we'll have a look at it.
Titel: Re: Logo with link to (any) homepage
Beitrag von: Kindred in September 06, 2019, 09:06:23 VORMITTAG
we need to see the ACTUAL line of text, with the actual url... I suspect that you changed something that should not have been changed....
Titel: Re: Logo with link to (any) homepage
Beitrag von: brenth in September 08, 2019, 01:26:18 NACHMITTAGS
The above is the actual line of text, and the actual URL was http://arkansaschurchsecurity.org/. I too thought I must have altered something though, as I mentioned I was careful not to change anything but what I indicated above.

In any case, after I could not get it to work I restored the original index.template file so that things would work again. Today I had the chance to go reinstate the change so I could upload the altered file here. However, this time it worked properly with no error. I am not able to determine what might have been different this time, but apparently there was some difference.

This is my first time to install and use the Simple Machines Forum and I appreciate your willingness to help me with my question.

Titel: Re: Logo with link to (any) homepage
Beitrag von: Arantor in September 08, 2019, 01:57:54 NACHMITTAGS
It would be helpful if you showed us the *exact* code you had, not 'here's what I did and here's the other part of it' because it sounds like when you edited it the first time, it wasn't edited correctly, and seeing exactly what you did matters for getting it right, though I guess it was right the second time.