Skip to main content
Nintex Community Menu Bar
Question

Variable Substitution of Text in Titles

  • July 9, 2024
  • 4 replies
  • 1 view
  • Translate

Forum|alt.badge.img+9

I have a page that has lots of references in page titles and templates to “Teacher”. I need another page that is identical, but with all the “Teacher” references changed to “Contact”. I tried setting up a top level javascript variable and then referring to it with {{}} in the title… but it does not render. Is there a way I can do this?

Did this topic help you find an answer to your question?
This topic has been closed for comments

4 replies

Forum|alt.badge.img+13

My recommended approach to this would be to use Custom Labels.

What you can do is to use the {{$Label.}} merge syntax throughout your page, and then use skuid.label.add to add new Labels to your page when the page first loads — for your purposes, this is essentially adding a global variable accessible via Merge Syntax.

1a. On the page(s) where you want it to say “Teacher”, add a new JavaScript Resource of type Inline - NOT Snippet/Component, with this body:

(function(skuid){ 
   skuid.label.add({
 'personLabel': 'Teacher'
 });
})(skuid);

1b. On the page(s) where you want it to say “Contact”, add a new JavaScript Resource of type Inline - NOT Snippet/Component, with this body:

(function(skuid){ 
   skuid.label.add({
       'personLabel': 'Contact'
   });
})(skuid);

  1. Throughout your page, use {{$Label.personLabel}} to merge in either Contact / Teacher:


  1. Save, and Preview your page. Your merges should come through.

Translate

Forum|alt.badge.img+9
  • Author
  • 108 replies
  • July 9, 2024

That works great Zack!  I have one place, a single field that shows for teachers but not students. Is there any way to read the merge variable and use it to control visiblity ?

Translate

Forum|alt.badge.img+13

There’s not a good supported way, no. A very hackish way would be to add some metadata properties to one of your Models and then access that via Merge Syntax, like this:

(function(skuid){&nbsp;<br>&nbsp; &nbsp;skuid.$(function(){ &nbsp; &nbsp; &nbsp; &nbsp; skuid.model.getModel('Contact').personLabel = 'Teacher'; &nbsp; &nbsp;});<u></u><br>})(skuid);


Then in your Merge templates you could do

{{$Model.Contact.personLabel}}


Translate

Forum|alt.badge.img+9
  • Author
  • 108 replies
  • July 9, 2024

I’m gradually beginning to get a feel for skuid. This is what I came up with, but I thouoght I’d check if there was a more built in way first… thanks Zach

Translate

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings