Skip to main content
1-Visitor
September 14, 2015
Question

Tables and callbacks

  • September 14, 2015
  • 1 reply
  • 2062 views

Hi, I'm new to ACL and am having trouble understanding tables and callback functions. I intend to add some tags to a recently inserted table. My first step is to add my callback function for any document  to be invoked after inserting a table:

doc_add_callback(0, table_insert_after, myCB)

Unfortunately, it seems like the code within myCB is never run. No errors when adding myCB and no messages when inserting a table in the editor. Anyone knows why this is happening?

Thanks in advance,

1 reply

18-Opal
September 15, 2015

Hi Mcevallos--

If that line of code you included is the actual code in your ACL, then the problem is probably just missing quotes. The second and third params of doc_add_callback() should be strings. Try something like this:

doc_add_callback(0, "tbl_insert_after", "myCB");

(Note also that it is "tbl_insert_after", not "table_insert_after").

Hopefully that will get you fixed up.

--Clay

mcevallos1-VisitorAuthor
1-Visitor
September 15, 2015

Hi Clay,

Thanks for your answer. You were right about the quotes and the misspeling, however it didn't change the response. Is there any other detail to have in mind while defining the function other than the number of arguments and being stored within a file in the custom/scripts folder?

Martin

18-Opal
September 15, 2015

Hi Martin--

Putting the script in the custom/scripts folder isn't enough to make it run automatically. To do that, you should put it in the editinit folder, which will make it run the script every time you open a new document for editing. Or, if you want to have it only apply to a certain doctype, you can put it in the instance.acl file in the doctype directory. See the Help Center topic on custom directory structure for more information on how scripts from different locations run at different points during an editor session.

--Clay