You are here: Home >> How-Tos >> Including Sources in Entries

How-To: Including Sources in Entries

By Brian Carnell

The single most annoying thing about reading other people's blogs and my blogs is link rot. I usually quote pretty extensively from any outside material, but even so I regularly read something I wrote a couple years ago or that someone else wrote and want to read the full text of the source cited. More times than not, however, the original source is no longer available on the web -- and if it's not a mainstream newspaper or similar source, it could be gone forever.

This upset me enough one day, that I created a solution in Conversant to simply store the full text of any sources cited along with the post. Not wishing to get sued, the sources are only available to the administrator, and you could narrow that further by restricting access to one particular individual or a member of a group if you have a site with many administrators.

This is pretty straightforward:

1. Create a new Long Text custom field to store the text of the sources. I call mine, Sources_Full_Text.

2. Add the new custom field to the your message editing template, like this:

<!--#msgcustomfield fieldname="Sources_Full_Text"-->

3. The final step is to set up the page templates to create a Sources link that will appear and pop-up the text if there is actually data in the Sources_Full_Text custom field.

a. First, I created a Directory Mirror page called "sources" in the root directory of the file structure.

b. Second, I modified my default template to redirect to a "sources" template if that directory mirror page is used. That looks like this:

<!--#elseif condition="requestPath contains '/sources/'"-->
<!--#insertTemplate name="Sources"-->> <!--#endif-->

c. Next, I had to create the Sources template referenced above. Here rather than the message itself, all I want is the content of the Sources field. So my template is just a single line,

<!--#msgCustomField fieldName="Sources_Full_Text"-->

d. Finally, I bring it altogether by adding a line to my Bound Message Template to display a special link if there is content in the Sources_Full_Text field,

<!--#if condition="userisconvadmin && msg.customField.Sources_Full_Text.value"-->
<><b><a href="<!--#siteurl-->sources/<!--#pagepath-->" target="_blank"-->Sources</b></p>
<!--#endif-->

The conditional first checks to make sure that a) the current user is the admin, and b) the sources_full_text field actually has daata in it.

The URL links to the directory mirror version, so we'll only see what's in the sources_full_text field rather than the text of the message, and opens a new window to display the text in.


QuickStart
Main Menu
Discussion

Guests
Welcome!
  • Sign Up
  • Logon

  • Search


    This site managed with Conversant, © Copyright 2008 Macrobyte Resources; Unless otherwise stated, content © 2000 - 2005 Mark Morgan
    Site design adapted from a free template at Free Site Templates.