Website Downloads Documentation Knowledgebase Wiki Issue tracker Commercial support

Query documents linked to the current document

Overview

Proiding a list of linked documents is a useful addition to many Daisy pages.  ( For example, documenting a server and having links to all the applications running on that  server. )  There are multiple ways of accomplishing this, and some confusion on the easiest way to create linked document lists.   This procedure shows some methods for making a linked document list via a query embedded inside a document.

Procedure

LinksTo

LinksTo searches all links to the page ID in parameter 1.  The following query would list all documents that contain links to the current page (assuming it is document ID 25).  The links can be in Link Fields, on the Links Tab, or in the Content.

select name where LinksTo(25,0,0) order by name

Or a more complex query including multiple fields and limiting to only one documentType

select name, $server_location, $server_type, $server_description where documentType = 'Server' and LinksTo(25,0,0) order by name

Unfortunately, the LinksTo parameters only take static entries, so ContextDoc(id) can not be used as parameter 1 of LinksTo.

LinksTo method works adequately for individual pages, but requires extra work if used in a document template as the document ID for the current page must be changed each time the template is duplicated.

Link field and ContextDoc(link)

Using a Link Field and ContextDoc(link) provides a method to query links without having to specify the Document ID in the query.  This method only looks in the field specified for links to the current document, so is not as universal as the LinksTo method above.   

This query shows all documents that link to the current document in the custom field server_links

select name where $server_links = ContextDoc(link) order by name

Or a more complex example

select name, $server_location, $server_type, $server_group, $server_ip, $server_description 
  where documentType = 'Server' and $server_links = ContextDoc(link) order by name

This method is better for use in a Document Template as the query does not need to be changed after each duplication.

Comments (0)
Advertisement

Daisy hosting, installation, support. Workshops and turnkey Daisy CMS projects. Get Daisy from its creators.

outerthought.org

Downloads provided by

SourceForge.net Logo

Open source stats