News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Same forum at .nl and .be, but a different logo?

Started by DutchJam, February 28, 2014, 02:56:32 PM

Previous topic - Next topic

DutchJam

Greetings!

This is the idea:
When a visitor points to www.jamaicaforum.nl the forum logo -an image- is (yeah right) JamaicaForum.nl.
But I also own www.jamaicaforum.be. Currently the visitor is -while going to www.jamaicaforum.be- redirected to jamaicaforum.nl showing the .nl logo. I want to keep it that way, but I would like to show a JamaicaForum.be logo.

I suppose I have to edit the default or theme index.template.php to do so, but no idea how.

Possible (or not)?

Thanx!
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

margarett

If the server remembers the address where it came from, then it would be possible. But I'm not sure if that happens...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

DutchJam

I think it does.

When I use:

<?php
echo $_SERVER['SERVER_NAME'];
?>


it returns .be or .nl, based on the URL I use in bowser's addressbar.

But when I try this:

    <h1 class="forumtitle">
    <img
        src="
            <?php 
            $pos 
strpos(".be/"$_SERVER['SERVER_NAME']); 
            if(
$pos !== false)
                {
                echo 
"logo_jmf_be.png";
                }
            else
                {
                echo 
"logo_jmf_nl.png";
                } 
            
?>

            ">
    </h1>


it returns only the .nl logo, no matter the URL I use...
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

margarett

I forgot to reply the other day, but I did some further search.
At that point, I got to see you should use this:

$_SERVER['HTTP_REFERER']

(what you're using it's the actual name, which explains why you have always the same logo)
The issue is, it only works the first page load after redirect... After that, it's gone. So, to make it work, you need to memorize whether or not it is redirected, probably in session or in cookie.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

DutchJam

Should I just replace $_SERVER['SERVER_NAME'] with $_SERVER['HTTP_REFERER'] ?

I tried in the script above, but the results seem the same.
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

margarett

I'm not actually sure if the slash should be there but I think not.

Just try to echo the variable before you work in in, just to see what it has.

Also, this might or might not work, depending on how the redirect is made. If the browser is unaware of the redirect, then it will not store those values...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Kays

Quote
'HTTP_REFERER'
    The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

If HTTP_REFERER was reliable then that would be the way to go. Since it's not, I'd go with the other suggestion and on the landing page for .be set a cookie (with no expiration) and check that instead on the .nl page.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Kays

* Kays was looking at the problem at hand rather than the overall picture.

Simpler yet, why not use $_GET?

On the redirect page add something unique to the url. Like: index.php?from_be

Then in the .nl forum check for that and set a session.


if (isset($_GET['from_be']))
  $_SESSION['from_be'] = true;


Now you should be able to used $_SESSION['from_be'] to toggle your banner.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

DutchJam

margarett:
$_SERVER['HTTP_REFERER'] doesn't work either as far as I can see...

Kays:
My knowledge of PHP is not that good I'm afraid...
How do I add 'something' to a URL? And do I check that in the .nl version?



-----
JamaicaForum.nl: http://www.jamaicaforum.nl

DutchJam

Ok, I got this lil script working:

<h1 class="forumtitle">
    <img
        src="
            <?php 
            $pos 
strpos($_SERVER['SERVER_NAME'], ".be"); 
            if(
$pos !== false)
                {
                echo 
"logo_be.png";
                }
            else
                {
                echo 
"logo_nl.png";
                } 
            
?>

            ">
    </h1>


It works perfect as 'stand alone' script, but my next problem is how to add this to the index.template.php of the theme I work on.

I assume I have to replace these lines in the index.templete.php file:

<h1 class="forumtitle">
<a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? '<img src="' . $settings['images_url'] . '/logo.png" alt="' . $context['forum_name'] . '" />' : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
  </h1>


But just 'cut and paste' (that would be tooooo easy :) ) does not work.

Anybody a tip?
-----
JamaicaForum.nl: http://www.jamaicaforum.nl

Advertisement: