neokoenig / cfwheels-shortcodes

A Shortcodes plugin for cfwheels
MIT License
5 stars 2 forks source link

application.shortcodes not persisiting #1

Closed timsayshey closed 10 years ago

timsayshey commented 10 years ago

The shortcode registers in onapplicationstart.cfm. If I dump application.shortcodes from inside addShortcode, I see my shortcode registered. But when I invoke the shortcode, I get nothing. So I dump application.shortcodes from inside $sc_invokeTag and the struct is empty.

Please advise.

Thanks!

timsayshey commented 10 years ago

Okay, I've narrowed it down. It looks like init is getting called after which contains "application.shortcodes={}". So it is clearing the shortcodes that I registered. So I removed it from init and put it in onapplicationstart.cfm, it works now. Not sure if that's how you meant it though.

neokoenig commented 10 years ago

onapplicationstart.cfm is where you want to register the shortcode. The actual shortcode function should be in events/functions.cfm, as otherwise the function data itself is persisted in the application scope, which is bad.

timsayshey commented 10 years ago

Right I am doing it exactly as you describe. Running addShortcode() in onapplicationstart. And the shortcode functions are in functions.cfm