0 Merge Field Context 2 Trey Hendon III posted 10 Years Ago I thought I had a cool idea, but it turns out the context of the Merge Fields is tied to the creator of the block, not the context of who's information I might be viewing. I'm trying to add a link to my Group Members Details that would take me to the Person's Page. I tried adding the following in a block on the Group Member Detail Page (140): <div class="text-right"><a href="/Person/{{ Person.Id }}" target="_blank" class="btn btn-primary">View {{ Person.NickName }}'s Record</a></div> Unfortunately, it is tied to my Id and NickName no matter which person's details I view. Has anyone figured out a way to get the context of the currenly viewed person's info exposed to the HTML editor? Is this possibly a bug in the scope of the Merge Fields?
Trey Hendon III 10 years ago Got this going after .10 upgrade and works great, thanks! Quick question, is there a way to find a list of what merge options are returned for the ContextEntity since it's not in the picker?
Trey Hendon III 10 years ago Turns out I was wrong, or misunderstand (very likely the case) the Context feature. Using the steps above, I found that the link only worked on the Group Member's page which I created the link on. So rather than always getting the Context of the GroupMemberId and giving me the current person's PersonId, somehow it also got tied to only displaying that link on the one record I was on when I created it. Does that make sense? Is that correct functionality?
David Turner 10 years ago Sounds like it might be caching. Did you set the cache duration to 0?. Currently, since context can be so dynamic, it's difficult to show available merge fields, but will take a look at trying to get them to appear in picker. If you know the object type, you could take a look at the model source (https://github.com/SparkDevNetwork/Rock/tree/develop/Rock/Model) and follow the properties there. What exactly are you trying to display? Also, FYI, the merge fields for context objects will change slightly in the next update 0.11 to support using merge fields for multiple context objects (instead of "ContextEntity.[Field] " you'll have to change it to use "Context.GroupMember.[Field]" ).
Trey Hendon III 10 years ago Good to know that will be changing, I'll keep an eye on it.I did check the cache because that was my first thought. I was trying to display that link from a Group Member Detail page to the corresponding Person Details page. But, what happens is it only displays the link when I view the one Group Member's Details page that I was viewing when I inserted the above code.Scenario: I was on Person A's Group Member Details page and followed the steps above. Then, when I viewed Person B's Group Member Details, the block doesn't display anything and if I edit the block while on Person B, the block Edit HTML is blank. However, as soon as I go back to Person A, the link appears as it was and the block's Edit HTML has all the code above still there.Rather than being a merge field for each GroupMemberId when the page is viewed it's like it's creating a new instance of the block tied to the GroupMemberId. Does that makes sense? Is that what it's supposed to do? (I could see this behavior as a cool feature too.)
David Turner 10 years ago Can you confirm that the "Context Parameter" and "Context Name" values for your HTML block are blank. The "Entity Type" under the Context section should be set to 'Group Member'. I suppose it might be a bit confusing that we have different 'context' settings. The Entity Type setting under the Context section is a way for the block to tell the page, "hey, I care about this type of object, load it into memory for me to use". The "Context Parameter" setting tells the block that whatever content you enter is specific to each value of that parameter. So if you set it to "GroupMemberId", then any content you enter when the query string has groupmemberid=1 will be different than when the page has a query string of groupmember=2.
David Turner 10 years ago Here's a sample content you could use as well...<a href='~/person/{{ ContextEntity.Person.Id }}'>{{ ContextEntity.Person.FullName }} Profile</a>
Trey Hendon III 10 years ago Brilliant! The Context Parameter and Context Name must have been it (I had deleted the block so I just recreated leaving them blank). I do remember populating them following the CMS Guide for using context. Great to know that BOTH types of context are available!
Trey Hendon III 10 years ago Yeah, I added the "Context Parameter" setting of "GroupMemberId" since the URL on the page is: /page/140?GroupMemberId=27I've also made sure the Cache Duration is set to "0".
Trey Hendon III 10 years ago For now, I found that I can use jQuery and access some hidden inputs ending in hfPersonId and hfPersonName to do what I need.