Software, your way.
burger menu icon
WillMaster

WillMaster > LibraryWebsite Development and Maintenance

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Revealed When Syndicated

Someone who syndicates content to other web sites 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.

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 website.

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 websites. 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 website, 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 website 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 website 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 website.

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 website, the JavaScript runs. When the article loads on other websites, the JavaScript doesn't run, because it's not there.

Thus, their version of the article contains no "Click here for a special announcement."

Will Bontrager

Was this article helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method

All information in WillMaster Library articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC