cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

adding a comment to ditamap

bfriesen
16-Pearl

adding a comment to ditamap

If you go to insert, comment (alt, ctrl, m) . YBryon

6 REPLIES 6

Hi Bryon--



You can do this with a pretty simple doc callback. Callbacks let you
respond to particular events. In this case, the insertion of a comment
tag is the event you want to respond to. Put this code somewhere in your
init ACL file:



function insert_tag_after_callback(doc, tagname, oid, op) {

if (op==1) { return 0; }

if (tagname == "_comment") {

goto_oid(oid);

insert("[" . username() . "]: ");

}

}



doc_add_callback(0, "insert_tag_after", "insert_tag_after_callback");



Now, when someone inserts a comment, it will be prepended with their
username, something like this:







with the caret positioned so the user can start typing comment content
after the colon.



See the Help Center documentation for doc_add_callback for details on
how callbacks work and how to define callback functions.



--Clay



Clay Helberg

Senior Consultant



TerraXML

1380 Forest Park Circle, Suite 100

Lafayette, CO 80027

Thanks again Clay. I find it hard to use the help when you dont know the proper terminology to search on. I will do some reading.



Bryon

Hey, Clay

Looks like there may have been changes to call-back functions in AE after ver 5.3.

I got following error when I tried your code as is in my AE 5.3 M110:

Wrong number of arguments to insert_tag_after_callback(): 3 passed, 4 expected
(at line 93 of file "C:\Program Files\Arbortext\Editor\packages\main\_docev.acl")

I checked AE 5.3 help for insert_tag_after callback type [help 148] and saw it had this function prototype:
funcname (doc, tagname, op)

So I changed the function to have 3 parameters (no "oid") as follows and it now works
as advertised:

function insert_tag_after_callback(doc, tagname, op) {
if (op==1) { return 0; }
if (tagname == "_comment") {
insert("[" . username() . "]: ");
}
}

Thanks for this,

--Jack

Thanks for the clarification, Jack. My projects tend to use current
releases of Arbortext, so that's usually what I test against, and
sometimes I forget that there are folks out there still using older
versions.



--Clay



Clay Helberg

Senior Consultant



TerraXML

1380 Forest Park Circle, Suite 100

Lafayette, CO 80027

Thanks Clay.I added the date_time() into the insert statement.


insert("[".username.()." ".time_date(est)."]:");


Do you have any advice on ridding the time from the output?



Thanks again,


Chris


According to the documentation, all the fields of the time_date() function are fixed width, so you should just be able to take a fixed substring, like this:



insert("[".username.()." ". substr(time_date(est),1,10) ."]:");



Clay Helberg

Senior Consultant



TerraXML

1380 Forest Park Circle, Suite 100

Lafayette, CO 80027
Top Tags