Forum Discussion

Beryllium's avatar
12 years ago

Where do you define macros?

I thought I read somewhere where macro's are suitable to be defined in lithium but I could not find it in the studio documentaiton. Can someone tell me?

 

Wrappers seems like the wrong place because I may want to use macro's across themes too. 

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)

    Hi,

     

    what you can do is to define your macros in a custom component (or more than one if you want to group them in a specific way) and then include that component when you need it. For example, say you have your macros defined in a component called common-macros , then you can simply include it from other components using the directive

     

    <#include "common-macros.ftl">

     

    And you will be able to use the macros when you need them in your components.

     

    Thanks,

    • AdamN's avatar
      AdamN
      Khoros Oracle

      In addition to what Paolo mentioned, there's also a "Macros" feature in Studio. To create a Macro:

      1. Browse to Studio
      2. Select the "Endpoints" tab
      3. Click the "New Macro"
      4. Enter a title and then save.

      Macros will appear in the "Macros" section below the "Endpoints" section in the left column. From there you can view, edit, or delete existing macros. The benefit of a macro is that it can be included not only in other custom components, but also in endpoints as well. So macros are great for code that you want to share to endpoints as well.

       

      If you don't see the "Endpoints" tab in Studio, please contact Support via the customer case portal so they can enable it for you.