Hello,

I have multiple URLs pointing to the same basic content. But each URL is for a different purpose, so I would like to be able to tweak the content of a page based on the URL that they user is visiting the content from.

So, if I have two domains:

chocolate.com and
caramel.com,

The basic content of the website will be about candy, but I want to change some of the text on the page to discuss chocolate or carmel depending on the URL that the user is visiting from.

If you might be able to help me with the code to get this set up I would appreciate it.

Comments

samdeskin’s picture

So far this is what I've got:

<script>
function writeSite(AA,BB,CC)
{var myDomain = document.domain;

if (myDomain == 'www.AA.com' || myDomain == 'AA.com') 
{document.write(AA);}

if (myDomain == 'www.BB.com' || myDomain == 'BB.com') 
{document.write(BB);}

if (myDomain == 'www.CC.com' || myDomain == 'CC.com') 
{document.write(CC);}

}
</script>
<script type="text/javascript">writeSite("text for Website AA","text for Website BB","text for Website CC")</script> 

The only problem is that the code appears on the page, so - so much or SEO. Also, Drupal seems to add a

<p> and </p>

on the page so it can't be used in a sentence to replace text.

Any help would be appreciated.

ainigma32’s picture

Status: Active » Postponed (maintainer needs more info)

If you want to output Javascript in a node you will need to change the input filter for that node. See here http://drupal.org/handbook/modules/filter for some basic info on filters.

You could also consider using the PHP filter and code the dynamic words in PHP. See here http://drupal.org/node/268716 for info on enabling that filter in case you haven't already.

Please post back how that works out for you.

- Arie

samdeskin’s picture

Arie, that helped a lot actually. I was having trouble placing a word in a paragraph because it wanted to put a break before and after the word. Now that break is gone!

The only other thing I am concerned about is getting the code out from inside the View Source. I need to get it out of there for SEO.

Any ideas?

dpearcefl’s picture

Is this still n active issue?

dpearcefl’s picture

Status: Postponed (maintainer needs more info) » Fixed

No response, so I'm going to assume this issue has been resolved.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.