Author: Peter_Jodeleit
Publication Date: 7/5/2010 9:26
With FirstSpirit 4.2 external links could be grouped in categories:
All links inherit the category of their link template (at creation time).
There are only two predefined categories ("url" and "email") but your can define your own categories.
The categories could be used as filter in the api method "getExternalReferences". The call below collects all external references with the catogory "email":
ReferenceEntry[] email_references_release = context.getProject().getExternalReferences("email", true);
René has posted a use case where categories come in handy: Periodically check of external urls.
Tested with FS4.2R2
Tags: categories, category, external, firstspirit, fs4.2r2, knowledgebase, link, linktemplate
Kommentare
5 Kommentare
I got some personal messages requesting how to define new categories. First i didn't understand the question until someone pointed out that there is a bug in the gui for the drop down box Category. If you type in some text and then directly switches to View mode the category is not saved. You have to click elswhere befor leaving the edit mode, then the value is saved. Refer to the (internal) issue id #83090, the status for the upcoming R4 release is resolved :smileywink:
I'm trying to script an external link checker and would like to use the category to define which links are to be checked. We have a total of 7 link templates, and only two of them should be checked. As category for these two templates, I typed "externalurl" into the combobox. (And clicked elsewhere before I saved. :smileywink:)
If I now use the following code, I get a refCount of zero:
refCount = 0;
// Check all released external links (selected via category "external_url", which is set in the link templates)
for (ref : context.project.getExternalReferences("externalurl", true)) {
refCount++;
// Perform the link check and react accordingly...
}
If I do the same code with "for (ref : context.project.getExternalReferences(true)) {", it works fine, except that of course all links are checked and not only the external URLs.
Could you give me some hint as to what I am doing wrong? I couldn't find any further documentation for the method "getExternalReferences" that would help...
Is there a way to access the category of a reference? (something like "ref.getcategory()")
Thanks
Guido
The gui-bug I referred to is fixed since version 4.2.401.
I'll try to check your code soon. In the meantime could you name your FirstSpirit version?
We currently use server version 4.2.223.40456
Your code works for me. Perhaps your content is not yet released? Try to iterate over the current references.
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.