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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Finding custom/doctype/..../instance.acl

ptc-3050150
1-Newbie

Finding custom/doctype/..../instance.acl

I found a great thread here on scripting making a flat file which I plan to use to back up the doc as it grows to 3000 chapters - yesterday two of those chapters emptied themselves at 10:05 am - declarations at the top and dozens of pages just gone.

My Question:

I've created a simple instance.acl but can't get it to load and need help on where to put it:

message "production/instance.acl found and read";
if (! menu_exists ("BAE")) {
menu_add -menu .Help "BAE";
menu_add .BAE. "Flatten This Doc" -cmd {flatten_this_doc();};
menu_add .BAE. " -separator;
menu_add .BAE. "Rewrite Entity Declarations" -cmd {set writeentdecls=roottreerefchildnone; save_all_docs;};
}

It is in \custom\doctypes\production\instance.acl. I also tried \custom\doctypes\production.acl with the same results.

Our doctype declaration:

I've read your posts and the ACL Guide and understand where to put it, but not what to name the directory I guess. I've tried /xml/ and no luck. The PE itself uses /custom/doctypes/Production so I tried that.

flatten_this_doc(); is located in my custom\init\johnsstuff.acl and it loads great...but you can't adjust menus there as they haven't loaded yet.

Sorry to ask such an idiot question...the menu commands work great cut-and-paste into the command line...just can't automate it.

John T. Jarrett
Sr. Tech Writer, BAE Systems

Arbortext version 5.4

LOGSA XSL-FO v 1.5

2 REPLIES 2
Alessio
15-Moonstone
(To:ptc-3050150)

The best practice to customize a menu is to load the menu through a
hook, not to put the code in instance.acl.

The hook will then be invoked on document open and in other
circumstances.





--- init.acl in init folder ---

require yourmenu;

function menu_hook(win, menu_path) { yourmenu::customize_menu_items();
}

function hook_yourmenu( ) { if ( ! terminal_mode() ) {
add_hook("menuloadhook", "menu_hook"); } }

hook_yourmenu();
--- end of init.acl ---



--- yourmenu.acl ---

package yourmenu;

require yourcommands; # declaring all commands used in these menu items
(-cmd option)

function customize_menu_items()

{

if (doc_type() == "production" && ! menu_exists ("BAE")) {

menu_add -menu .Help "BAE";

menu_add .BAE. "Flatten This Doc" -cmd {flatten_this_doc();};

menu_add .BAE. " -separator;

menu_add .BAE. "Rewrite Entity Declarations" -cmd {set
writeentdecls=roottreerefchildnone; save_all_docs;};

}}

--- end of yourmenu.acl ---





As to why instance.acl is not invoked: 70% of the times this happens
because the DTD is not located in the same folder where you put
instance.acl

This usually happens if you have two customs, the latter customizing the
former and the DTD is only located in the former.








Beautiful! Thanks for the explanations. And, yes, our DTD is on the server, not our local machines, so that explains why it couldn't find it in doctypes.

I put init.acl in /custom/init/ and yourmenu.acl and yourcommands.acl in /custom/script/ and it works beautifully.

Now off to learn more about hooks.

Thanks VERY much, Alessio!

John T. Jarrett
Sr. Tech Writer, BAE Systems

Arbortext version 5.4

LOGSA XSL-FO v 1.5

Top Tags