Definition – 'content sharing' means: offering the contents of a webpage to another website to directly insert into its own page. It is not the same as 'content management', the system by which a number of contributors automatically add or update content to a single website.
Content sharing has a number of advantages. The recipient site obtains added-value by the instant creation of additional pages, ready-written by other people. The donor writer receives additional readers for his or her material, and the donor site receives added exposure via a link on the shared page.
There are several ways of calling up the contents of a page into a recipient site. The method described here uses the Javascript insert method. The user adds a line of code which calls up a file containing the contents of the page, which has been 'parsed' (converted) into Javascript. This method of content sharing is explained here. If you only have a small number of unchanging pages to offer, then it is easy to convert them into Javascript, and place the files on your server for easy linking.
However, if you have a large number of pages that you wish to offer, which may also be frequently updated, there would be considerable work involved in maintaining and updating a duplicate set of pages as Javascript files. The system explained on this page uses PHP to automatically parse into Javascript, any page within a site. Once set up, it is therefore a great time-saver. All the pages on this site are available to insert using this method.
Although there is a more elegant CSS solution, you could also use it to create a second version of a page within your own site which is 'printer-friendly'. It can remove graphics, navigation bars, etc., and allows CSS to set narrow margins and font size at say, 12pt serif – an ideal printer setup.
Other methods of content sharing which involve text 'hard-coded' into the page (e.g. normal PHP insertion, or permission to copy/paste the text) are dangerous because they create duplicate content visible to search engines. Any system of content-sharing using 'hard-coding' must be combined with a no-robots meta tag on the page (or in the root directory). It is difficult to expect users to understand this issue and always add no-robots commands to their pages. Without such a guarantee, hard-coding is a dangerous option to offer.
<noscript>
line to the page, for the small percentage of people who have Javascript disabled.
You can view the instructions to potential users offered at the end of almost every page of this
site, with an extra page of tips as a side link.
This system will capture web-pages with any file extension: .html, htm, .php, etc.
Furthermore, if you currently have webpages ending in the standard .html or .htm file extensions, it may be possible
for you to use PHP without changing your page file extensions to 'php', which would spoil all
your incoming links, bookmarks, search engine listings, etc. Talk to your site host.
If you are not already routinely using PHP, this represents an incredible increase in
versatility for you, without any of your page URLs needing to change.
If your server cannot handle PHP, all may not be lost! Find a friend with some spare bandwidth, whose server does handle PHP, and ask if they can host the single PHP script required to make this system work. The script will still work with full paths specified. You can still use a single site-wide insertion code, modified by Javascript, as explained later.
getPageContent.php. Note – this code is the entire content of that page, which must not
contain anything else such as head or body tags. Save the page in the same directory as your
pages to be parsed, or anywhere else if you define the correct path to it. (It could even be
on a friend's server if you do not have access to PHP.)
<?php
// this PHPtoJavascript converter is available from web-evangelism.com/resources/content-sharing.php
function getPageContent( $url ){
return( implode( file( $url ), "" ) );
}
function parseContentByTagName( $content ){
preg_match_all( '/<div id="mycontentuniqueID">([\n\r\w\W.]*?)<\/div>/i', $content, $contentArray );
return( implode( $contentArray[0], "" ) );
}
if( $pageID == "" )
print( "You have passed an invalid page, please include the paramater: pageID" );
else{
$pageContent = getPageContent( $pageID );
$pageContent = parseContentByTagName( $pageContent );
if( $pageContent == "" )
print( "document.write( \"<ul><li><a href='http://www.yoursite.com/pages/$pageID'>Click here for Yoursite Name page: $pageID</a></ul>\" );");
$pageContent = str_replace( '"', '\"', $pageContent );
$pageContent = str_replace( "\n", " ", $pageContent );
$pageContent = str_replace( "\r", " ", $pageContent );
$copyrightDate = date("Y"); $pageContent = $pageContent . "<p><span style=\'font-size=80%;margin-left:3em;\'>© $copyrightDate web-evangelism.com. Used by permission. <a href=\'http://www.yoursite.com/pages/conditions.php\'>Conditions for re-use</a></span><p><ul style=\'margin-left:3em;\'><li>Visit the <a href=\'http://www.yoursite.com\'>Yoursite Name</a> for more pages on the subject of whatever</ul>";
print( "document.write( \"" . $pageContent . "\" );" );
}
?>
Relative-link version$mydomain = 'http://www.yoursite.com/directory/';):
";
print( "document.write( \"" . $pageContent . "\" );" );
}
?>
div id="mycontentuniqueID" and the closing marker is /div. However, if the main content of your
page contains other divs, the code will look for the first closing /div as an end marker. Therefore you would need to
add further opening markers. But in fact, your markers can be anything. For instance
span id="mycontentuniqueID" and /span work – though the same issue applies if you have closing
span tags within the page.
You can also use notional class tags <p class="start"> and <p class="end"> as markers.
If all your pages have consistent coding, you can even designate existing elements of page code within them as starting
and ending markers. This will save you having to add markers to all your pages. For instance,
if you want your own header included, you can designate h1 as the starting marker,
or any existing div class=" or p=class=" tag. Then choose some other
consistent code element near the end of the page as a closing marker – for instance
a href="homepage.html" or the opening code for any end navigation menu.
If you are using CSS to specify several blocks of content on your page such as top navigation bar, main page content,
and footer (for instance something like class="topnav", class="maincontent", class="footer", then you can
use the class="maincontent" tag as your opening marker and class="footer" as your closing marker.
(This is assuming that you don't have any elements of content within the "maincontent" text area you wish to exclude.)
<span style="color:red;font-size=80%;margin-left:3em;">page element here</span>
$pageContent = str_replace( '"', '\"', $pageContent );which the script will add into the body of the recipient's page, above the inserted text, thereby adding to the recipient's overall style sheet. Add the style elements in a single line like this example:
$pageContent = $pageContent . "<style type=\"text/css\"><!--div.box { border: solid; border-width: thin; border-color: red; width: 30%; padding: 6px; font-size: 75%; color: red; float: right; text-align: left; }--></style>";
Note how the style sheet has been placed in one line, and double quote marks are escaped with backslashes.
Do not use more than the bare minimum of style necessary for correct rendering of your page content. The whole point of content-sharing is that the content blends seamlessly into recipients' pages, and follows the style they wish to set.
<script language="JavaScript" src="http://www.yoursite/pages/getPageContent.php?pageID=mypage.html" type=text/javascript>
</script>
and it is wise to encourage them to include a noscript line too, so that their page will make sense to people with Javascript disabled:<noscript>Click here for <a href="http://www.yoursite.com/pages/mypage.html">Name of page here</a> - short explanation about page </noscript>where
mypage.html is of course the specific file name of the page they wish to insert into their site.
You will see how this site offers the insert code at the end of nearly every page, within a small textarea from which it is easy to highlight and copy the coding.
Note that the insert script will not operate on your hard drive. The page must be viewed online in order for the script to operate. You must do testing online, unless you have a PHP emulator on your hard-disk.
<?php $subject = "Design"; ?> and <?php $shorttitle = "Content sharing"; ?>
which also customize the 'bread-crumb trail' at the top of the page. The inserts appear like this in the source code for this page:
src="http://guide.gospelcom.net/resources/getPageContent.php?pageID=<?php echo $file_name = basename($PHP_SELF); ?>"and within the noscript tag:
Click here for <a href="http://guide.gospelcom.net/guide/resources/<?php echo $file_name = basename($PHP_SELF); ?>"><?php print $shorttitle; ?></a> a section within <b><?php print $subject; ?></b> subject area of the <b>Web Evangelism Guide</b>.The actual source code on your page will have angle brackets coded by
< and
>, with the exception of the brackets around the PHP echo commands, in order
to produce visible html code for users to copy, which will appear similar to that at the end of this page in the
'Free Content' box.
A second PHP way to grab the page title for insertion into the noscript text is demonstrated here.
By PHP: Creates insert code by grabbing the both the file name of the referring page and its title, with PHP.
This will automatically create a custom jump-code and <noscript> wording for users to copy:
demonstration and code.
By Javascript: If you do not have access to PHP on your server, and have asked a friend to host your
getPageContent.php file, you can also use a single site-wide explanation page,
using Javascript to insert the file name of the page into the copy/paste jump-code, rather than PHP:
demonstration and code.
Iif you are using this script on a page intended for a Christian readership, please could
you include a link to the Guide homepage:
http://guide.gospelcom.net/index.php
If you use this script on any other sort of site, please consider a link to this page:
http://guide.gospelcom.net/resources/content-sharing.php
If you use the system, we may be able to list your site here as demonstration to others. Please
.
If you have never thought about the meaning of life before, why not investigate.
|
FREE AND SIMPLE: Syndicate this page's content into your site • Insert this page's text directly into your own website. then copy/paste (CTRL+C/CTRL+V) this Javascript code into your own page: help | example. (Please DO NOT copy the actual text of this page onto your own site: reasons.) Other options for re-use. • Or please link to this page • Add a Bulletin subscribe form to your site. |
Latest Bulletin: |
© Dec 2008 Web Evangelism Guide Contact us Sitemap Privacy About us Meaning of life
|
|
|