Aller au contenu principal

Call script template from another script template

Commentaires

4 commentaires

  • Zendesk API User
    Author: felix_reinhold - 7/5/2019 8:20

    Hello Andres,

    there might be ways e.g. by using the RenderingAgent but you should definitely put those common functions in a FirstSpirit Module - that's the cleaner and more common approach.

    Best regards

    Felix

    0
  • Zendesk API User
    Author: robin_kump - 7/5/2019 9:01

    Hello Andres,

    Take a look at:

    //!Beanshell

    import de.espirit.firstspirit.access.store.Store;

    import de.espirit.firstspirit.access.store.Store.Type;

    import de.espirit.firstspirit.access.project.TemplateSet;

    String getScript(uid) {

        TemplateSet firstTemplateSet = context.getProject().getTemplateSets().get(0);

        return context.getUserService().getStore(Store.Type.TEMPLATESTORE, true, true).getScripts().getScriptByName(uid).getChannelSource(firstTemplateSet);

    }

    eval(getScript("<UID>"));

    That's the way we load Scripts from the project and execute them within Server Tasks sometimes. Technically not very sophisticated, but it works and completely sufficient for small scripts.

    Best regards

    Robin

    0
  • Zendesk API User
    Author: felix_reinhold - 7/8/2019 11:49

    @Andres

    Just as a small advice if you're planning to use Robins solution:

    Since you are talking about a Render-Script yoou should implement sth. like a lazy loading for the script source - otherwise you would obtain it again for each render-call. This could be easily implemented with a small CMS_SET block-statement within the projectsettings template.

    best regards

    Felix

    0
  • Zendesk API User
    Author: agarcia - 7/10/2019 11:09

    After thinking about it, I would go for with Felixs solution because I have big scripts to be imported.

    Although I think Robins solution can be very useful in certain cases.

    Thank you all!

    0

Vous devez vous connecter pour laisser un commentaire.