How do I set this up the right way, transferring from Wordpress as CMS?
Macros are intended to output to the page, rather than return data to the caller. If you must return the data, I'd suggest writing a custom plugin (although that's where my knowledge stops!).