Welcome, guest ( Login )

» Home (JDC Blog)
» Forums

Page Tags

tag tags tagging plugin experiment project dojo

Search Tags:
WikiHome » WikiZone » CommunityExperiments » JotTaggingExperiment » RelatedPagesDynamicV1

RelatedPagesDynamicV1

Version 3, changed by TimJones. 03/06/2006.   Show version history

RelatedPagesDynamic V1

Pages:

  • RelatedTagsDynamic plugin
  • RelatedTagsDynamicLib -- the javascript that retrieves and displays related pages. Reusable outside the plugin.
  • TagCloudLib2 -- adds 1 function to the previous version, that displays a tag cloud with modified links.
  • MultiTagPivot -- the page that generates a list of related pages for multiple tags.
    • Note that sys/templateAlternateView for this page is set to view-raw -- this strips all the chrome off to make this page smaller. It's loaded using a dojo.io.bind() call when a tag is clicked.

These pages are available as a package you can install, too.

What's going on? (Editing tags)

The "tag this page" link shows a hidden div with a form in it:

<div id="relatedtags-editBox" style="display:none">
<form action="javascript:void()" onSubmit="saveTags(pageTags.value)">
<input type="text" name="pageTags" value="${translate(page/main/tags, '[]', '')}" />
<input type="submit" value="Update tags" />
</form>
</div>

When the submit button is clicked, a dojo call posts the form:

function saveTags(newValue) {
	var arr = new Array();
	arr["pname1"] = "main/tags";
	arr["pvalue1"] = newValue;
	var thisPath = "${page/path}";
	arr["path"] = thisPath;
	arr["form"] = "/TagForm";

	dojo.io.bind({
		url: dojo.uri.joinPath(djConfig.wikiRootPath, "/_/cmd/saveForm"),
		method: "post",
		content: arr,
		handler: function(type, resp, e) {
                   if (e) {
                     window.location.reload(true);   //refresh the page
		   }
		},
              	mimetype: "text/plain"
	});	
}

What's going on? (Displaying related pages)

When a tag is clicked, a function called updateTagDisplay() gets called, and updates the list of highlighted tags. Then another dojo.io.bind call retrieves the list of pages and inserts it into the document:

function displayRelatedPages (theTags, displayDiv) {
var arr = new Array();
arr["tag"] = theTags;
arr["page"] = "${page/path}";

	dojo.io.bind({
		url: dojo.uri.joinPath(djConfig.wikiRootPath, "/MultiTagPivot"),
		method: "post",
		content: arr,
		mimetype: "text/xml",
		handler: function(type, xml, e) {
			if(type == 'load') {
			  // just throw the whole response text into the div's innerHTML...
			  // this isn't really ideal, but I had trouble getting at the response in IE otherwise.
			  document.getElementById(displayDiv).innerHTML = e.responseText;

			  // make sure the div is visible.
			  document.getElementById(displayDiv).style.display = 'block';
			}
		}
	});
}

Attachments (0)

  File By Size Attached Ver.