Global Variable in Nosto Templates — Nosto Community

Global Variable in Nosto Templates

debug_gurudebug_guru Posts: 15Member
How do I set any global variable which can be used in all the Recommendation template and email templates?


  • KonstantinKonstantin Posts: 26Walking Wisdom admin
    Hi @debug_guru
    Do you have an example or scenario that I could follow to get an idea on how to help?
    Much appreciated B)
  • debug_gurudebug_guru Posts: 15Member
    Hi @Konstantin,

    We are sending number of emails via Nosto to our customer.

    In email the we are sending a promotional(Which is same) banners which gets updated weekly.

    Now when I need to update this banner had to open each and every email template and update the banner.

    Thus asking if there is any way that I can assign global variable and use the same in email template or recomendation template.

    With this implemented I had to just update image link in the global variable and it reflects to all the email template or recomendation template where I have integrated.

    Similarly If I need to update common text or t&c in email templates, I had to open all the email templates.

    So if there is option for global variable then lot of time can be saved.

    Please look on to this if there is a way?

  • JacopoJacopo Posts: 47Walking Wisdom, Coding Expert admin
    Hello @debug_guru

    Each template (email, rec slots, etc.) is a distinct "entity therefore you cannot set a single, unique global variable which is read and interpret by all the templates BUT you can set a global variable on each template.
    For example, if at the top of the template you write

    #set($banner = "")

    then you can just use the variable $banner in the src attribute of the <img>, example

    <img src="$banner"/>

    in this way, if more than one image container serves the same banner, you will just have to update the link at the top of the template.

    Same goes for string, example

    #set($message = "This week 50% on all shirts")

    then you can use


    I tried to be the clearest possible but if you still have got some questions, I am here for help :D 
  • debug_gurudebug_guru Posts: 15Member
    Hi @Jacopo,

    Thank you for clarification but I am still not clear.

    I do understand that the email templates are unique but there are some variable which I believe is set at account level like ($!visit.restoreLink,

    These variables I believe is fixed one, similar can't there be any variable option which can be used account wise accordingly.

    Also you mentioned that the variable can be declared in the templates and used the same as required.

    But what if I have declared the variable $banner1 with src of image in my template A, and in template B I have to use same image url so I just used $banner1 which was declared and assigned in template A.

    So will this work or do I have to declare and assign the src image link again in template B.

    If yes then I would say it would be not global variable, it would be variable which is restricted to that template only.

  • JacopoJacopo Posts: 47Walking Wisdom, Coding Expert admin

    I guess you have read my answer when I have written "you can set a global variable on each template" - that variable will be global for the template (global as per its usage is not restricted to the scope of a function) but yes, for another template you will have to declare it again.

    In your example, $!banner1 will have to be declared in each template.

    The variables you have mentioned are generated by Nosto and related to the shop - so to speak they should be treated more as constants, and not variables.

    I hope this helps! :)
  • debug_gurudebug_guru Posts: 15Member
    Hi @Jacopo

    I understand but I was looking for some thing which can be declared once and can be used in multiple templates including emails.

    And update the same as per requirement either weekly or every alternate day.

    But for now Nosto dosen't seems to support the same :( .

  • JacopoJacopo Posts: 47Walking Wisdom, Coding Expert admin
    Why not posting your suggestion in the "Ideas" discussion? Our devs read that regularly, so if it is something which could be used by our Customers I am sure they will develop something as such.
  • debug_gurudebug_guru Posts: 15Member
    How do I reach this section "Ideas" Discussion?
Sign In or Register to comment.

Read our Terms&Conditions before commenting and posting