mattgadient.com

Joomla, SJSB, and SMF – displaying different things on different sites

I use a wrapper (SJSB) to show my SMF forums on my Joomla site.

Tiny issue is that the text shows up quite small on the Joomla site. It’s alright for me, but if anyone’s got poor eyes, a tiny screen, or a high resolution, it’d be brutal. I could have changed the CSS to simply make it bigger, but the smaller size actually suits the site.

To compromise, I decided I’d give a link to go to the “full” forums (which has a normal, larger size). Now, both sites share the same code, which means that link would normally show up on both. “click here to go to [exact same site] if the text is too small” would be a little silly.

Luckily, I came up with a simple php solution. It goes like this:

if (($_SERVER[‘SERVER_NAME’]==“www.eyeglassretailerreviews.com”)) {
echo ‘<span style=”font-size: 12px;”>Too small to read?</span><br />‘;
echo ‘<span style=”font-size: 12px;”><a href=”//forums.eyeglassretailerreviews.com”>Click here to go to the full-size forum!</a></span>‘;
} else {
echo ‘<span style=”font-size: 16px;”>You are visiting the FORUMS!</span><br />‘;
echo ‘<span style=”font-size: 16px;”><a href=”//www.eyeglassretailerreviews.com”>Click here to go to the EyeglassRetailerReviews.com Website!</a></span>‘;
}

This basically compares the fields in orange. If they’re equal, it does the first section under if. Otherwise, it does the stuff under else. Pretty much anything related to the php code is in black. The html formatting is in purple, and what actually ends up on the screen is in blue. Note that I didn’t *need* an else section – I decided to put it there simply to make it easy for people to head back to the main site if they wanted to.

In this case, if you were on the www.eyeglassretailerreviews.com site, you would see:

Too small to read?
Click here to go to the full-size forum!

If you were NOT on the www.eyeglassretailerreviews.com site (for example, if you were on forums.eyeglassretailerreviews.com instead), you would see this:

You are visiting the FORUMS!
Click here to go to the EyeglassRetailerReviews.com Website!

Simple, yet elegant! A different message and font for each site.

I incidently used the same concept to show ads based on what site they were on.

0 Comments

 | Leave a Comment

    Leave a Comment

    You can use an alias and fake email. However, if you choose to use a real email, "gravatars" are supported. You can check the privacy policy for more details.

    To reduce spam, I manually approve all comments, so don't panic if your comment doesn't show up immediately.