Revealed When Syndicated
Revealed When Syndicated
A short time ago, a customer who uses Master Syndication Gateway V2 for
monitoring content being syndicated had an interesting
question:
Could a system be devised to allow some specific parts of
content to be published on remote sites but not published on
his own site, without requiring the creation of two
different files?
This is the system we came up with. It works quite nicely
without any changes necessary to the Master Syndication
Gateway V2 software.
Let's suppose your web pages have a copyright line already on your web pages. It could be redundant to publish a copyright line with your own articles on your web site.
Yet, when the article is published on other sites, the copyright line should be there.
Create a CSS class name that is unlikely to be used on any of the other web sites. In that class, specify a display:none rule. Example:
<style type="text/css"><!--
.unlikelytobeduuplicated { display:none; }
--></style>
Now, put your copyright notice in the content on your web page at the location you want it printed when syndicated. Wrap the notice in span (or div or other) tags specifying the special class you made. Like:
<span class="unlikelytobeduuplicated">
© Bontrager 2007
</span>
The effect is that, on your web site, the class hides the copyright notice. However, when the content is syndicated, the copyright notice is visible and printed where you want it. It works that way because the remote web site does not have that particular class name defined.
Doing the Reverse
If your situation is the other way around, you publish content in your articles that should not be published when syndicated, like a site announcement, say, then it may be handled this way.
For an example, we'll suppose you want the word "Click here for a special announcement" to appear in the article on your web site but not in the same article published on others.
Put this into your article:
<span id="unlikelyname" style="display:none;">
Click here for a special announcement.
</span>
(It could be a div or other tag, instead of span.) The above will print only when certain JavaScript is run, JavaScript only on your web site.
Put the JavaScript somewhere below the article and not part of the article:
<script type="text/javascript" language="JavaScript"><!--
document.getElementById("unlikelyname").style.display = "block";
//--></script>
Notice that the "unlikelyname" in the JavaScript is the same as the "unlikelyname" for the id in the span tag containing "Click here for a special announcement." They must be identical. If one "unlikelyname" is changed, both must be changed.
When the article loads on your web site, the JavaScript runs. When the article loads on other web sites, the JavaScript doesn't run, because it's not there.
Thus, their version of the article contains no "Click here for a special announcement."
Question:
Did you find this article interesting and understandable? How can it be improved?
Your response is anonymous.
When done typing, click anywhere outside the box. [more info]
Will Bontrager
©Copyright 2007 Bontrager Connection, LLC Bontrager Connection, LLC
Please note:
Articles on this website are presented "as is". However -
If you have a question about a CGI script, HTML, CSS, PHP, or JavaScript
Ask one of our Experts and you'll have your answer!
Click here for details.