ElkArte Community

Project Support => Support => Topic started by: Jorin on May 15, 2018, 05:53:03 am

Title: Footer links
Post by: Jorin on May 15, 2018, 05:53:03 am
I tried to add a link to a thread into the footer right after the credits link. Can anyone help me please?

Code: [Select]
function template_body_below()
{
global $context, $txt;

echo '
</div>
</div>';

// Show RSS link, as well as the copyright.
// Footer is full-width. Wrapper inside automatically matches admin width setting.
echo '
<div id="footer_section"><a id="bot"></a>
<div class="wrapper">
<ul>
<li class="copyright">',
theme_copyright(), '
</li>',
!empty($context['newsfeed_urls']['rss']) ? '<li>
<a id="button_rss" href="' . $context['newsfeed_urls']['rss'] . '" class="rssfeeds new_win"><i class="largetext fa fa-rss"></i></a>
</li>' : '',
'</ul>';

// Show the load time?
if ($context['show_load_time'])
echo '
<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
}
Title: Re: Footer links
Post by: Ruth on May 15, 2018, 06:38:16 am
I guess, a link in the footer has to be added somewhere here:            

Code: [Select]
theme_copyright(), '
</li>',

That way:

Code: [Select]
theme_copyright(), '
</li><a href="http://something.de">| Text</a>',

But I am not sure O:-)

Title: Re: Footer links
Post by: Jorin on May 15, 2018, 07:12:21 am
You were absolutely right, thanks!  :)
Title: Re: Footer links
Post by: badmonkey on May 15, 2018, 08:46:07 am
It may not matter, but just to put the idea out there.  The SimpleAds mod does footer ads.  You can place html links as an "ad" right where you're proposing.  Best of all it's hook based, so no keeping up with hardcoded mods.   ;)  Take a look at bbs.zuwharrie.com as an example.   ;D
Title: Re: Footer links
Post by: Antechinus on May 19, 2018, 05:43:05 am
The correct way of doing it would be:
Code: [Select]
function template_body_below()
{
global $context, $txt;

echo '
</div>
</div>';

// Show RSS link, as well as the copyright.
// Footer is full-width. Wrapper inside automatically matches admin width setting.
echo '
<div id="footer_section"><a id="bot"></a>
<div class="wrapper">
<ul>
<li class="copyright">',
theme_copyright(), '
</li>
<li>
<a href="http://something.de">| Text</a>
</li>',
!empty($context['newsfeed_urls']['rss']) ? '<li>
<a id="button_rss" href="' . $context['newsfeed_urls']['rss'] . '" class="rssfeeds new_win"><i class="largetext fa fa-rss"></i></a>
</li>' : '',
'</ul>';

// Show the load time?
if ($context['show_load_time'])
echo '
<p>', sprintf($txt['page_created_full'], $context['load_time'], $context['load_queries']), '</p>';
}
Ruth's suggestion omits the <li> tags, which will invalidate the markup. ;)
Title: Re: Footer links
Post by: emanuele on May 19, 2018, 10:45:04 am
O_O
OMG a ghost.
Title: Re: Footer links
Post by: Jorin on May 23, 2018, 12:38:27 am
Quote from: Antechinus – The correct way of doing it would be:
...

Okay, but the text size of my links is now bigger then the copyright link. It shouldn't be. Can you help me again please?
Title: Re: Footer links
Post by: emanuele on May 23, 2018, 03:00:42 am
Give the <li> a class "copyright":
Code: [Select]
					theme_copyright(), '
</li>
<li class="copyright">
<a href="http://something.de">| Text</a>
</li>',
Title: Re: Footer links
Post by: Ruth on May 23, 2018, 04:51:04 am
Thank you!  :)

I did it that way now, because the  | were getting too small or too large, if they are anywhere else:

Code: [Select]
	theme_copyright(), '
</li>
<li class="copyright"> | <a href="http://something.de">Text</a></li><li class="copyright"> | <a href="http://something2.de">Text2</a></li>',
Title: Re: Footer links
Post by: Jorin on May 28, 2018, 01:42:26 pm
Thanks, Ruth. Works perfect and looks good!
Title: Re: Footer links
Post by: Jorin on May 29, 2018, 01:15:30 am
A little hint, thanks to @radu81: If you are using complete URLs like https://forum-alternative-antriebe.de/index.php/index.php/topic,467.0.html guests or other not logged in users must click two times on the links to open them. The first click only leads to board index. Strange!

When you change the URL to ' . $scripturl . 'index.php/topic,7255.0.html, everything works fine even with the first click!

So my code looks like this now:

Code: [Select]
	// Show RSS link, as well as the copyright.
// Footer is full-width. Wrapper inside automatically matches admin width setting.
echo '
<footer id="footer_section"><a id="bot"></a>
<div class="wrapper">
<ul>
<li class="copyright">',
theme_copyright(), '
</li>
<li class="copyright"> | <a href="' . $scripturl . 'index.php/topic,467.0.html">Nutzungsbedingungen</a></li>
<li class="copyright"> | <a href="' . $scripturl . 'index.php/topic,7773.0.html">Datenschutzerklärung</a></li>
<li class="copyright"> | <a href="' . $scripturl . 'index.php/topic,7255.0.html">Impressum</a></li>',
!empty($context['newsfeed_urls']['rss']) ? '<li>
<a id="button_rss" href="' . $context['newsfeed_urls']['rss'] . '" class="rssfeeds new_win"><i class="icon icon-margin i-rss icon-big"><s>' . $txt['rss'] . '</s></i></a>
</li>' : '',
'</ul>';
Title: Re: Footer links
Post by: radu81 on May 29, 2018, 06:12:18 am
Have you tried to change those links with something like index.php?topic=xx? 
Title: Re: Footer links
Post by: Jorin on May 29, 2018, 07:52:05 am
Without leading "scripturl"?
Title: Re: Footer links
Post by: emanuele on May 29, 2018, 01:16:34 pm
Probably $scripturl includes already index.php. :P
Code: [Select]
<a href="' . $scripturl . '?topic=467.0"
would do.
Also, try to always use the above schema, because it is rewritten into the "html" form before being sent to the user and is more "future-proof" (i.e. if something will change in the future, the ?topic form will be for sure properly handled, the "topic,123.0.html" may or may not).
Title: Re: Footer links
Post by: Jorin on May 30, 2018, 01:32:51 am
Thank you. I changed the code.  :)
Title: Re: Footer links
Post by: Mattmax on August 21, 2018, 04:55:22 pm
Quote from: Jorin – Thank you. I changed the code.  :)
Hello, I like the way you did it.
Can someone give me a tip in which file I have to do the changes?
Title: Re: Footer links
Post by: Jorin on August 22, 2018, 01:15:56 am
Thank you. You will find the code in themes/yourtheme/index.template.php. If your theme doesn't have a special index.template.php file in his folder, the file from themes/default is used.
Title: Re: Footer links
Post by: Mattmax on August 22, 2018, 05:04:53 am
Thank you for this information.