MK's Tips & Tricks #2: Grab a page's assigned security category without session variables

Options

Happy Thanksgiving to all my US compatriots! Before I set off myself for the long weekend, here's a nuanced tip for some more robust code:

I'm not fond of session variables – the kind set with [[U]] tags, anyway (no complaints about URL-based ones, so far). It is really quite rare, but often enough to be an annoyance that a session variable defined in my wrapper won't be set properly, so for the most part I've moved away from [[S80]] wherever I can.

Now, I have some PageBuilder pages whose names lead off with security category strings, and I have pages in different security categories which will be pulling slightly different data from this set of PageBuilder pages. Let's say, category 1 is MYCAT_SUBCAT1_ and category 2 is MYCAT_SUBCAT2_, and the PB page is simply called Data. I need the first site to load MYCAT_SUBCAT1_Data and the second site to load MYCAT_SUBCAT2_Data, but I'm lazy and want to write a single line to do it dynamically. The solution is thus:

[[E51:[[E53:[[S42:0:sec-cat]]]]Data]]

Breaking this down, we see it's in three parts – the real meat being the [[S42]] tag embedded in the [[E53]] tag. It should be noted here, in the event one is not aware: S-tags and E-tags are identical in functionality, except that an E-tag tells Luminate it must wait for other E-tags or S-tags within it to resolve before resolving the bounding tag; S-tags alone can't be nested inside each other. If you need to know what a given E-tag is doing, look up its S-tag counterpart. [[S42:0:sec-cat]] tells Luminate to pull the security category ID# (that is, the parameter sec_cat – which, strangely, is not to be found in the official S-tag docs) for the given fr_id; in this case, fr_id "0", which is a shorthand way of saying "whatever the fr_id is of the page this code is on". [[E53]] will take a security category ID# and produce the string associated with that security category; so, if [[S42:0:sec-cat]] resolves to 6789, then [[E53:6789]] will resolve to the string associated with that category.

The final piece is the bounding [[E51]] tag. [[E51]] loads-in-place a PageBuilder page with the given title, a title which should be completed by the [[E53:[[S42:0:sec-cat]]]]Data component.

Step-by-step, this all means that if my first site is in MYCAT_SUBCAT1_, and the ID# for that category is 9999, then [[S42:0:sec-cat]] will resolve to 9999; [[E53:9999]] will resolve to the string MYCAT_SUBCAT1_, and [[E51:MYCAT_SUBCAT1_Data]] will load the page titled "MYCAT_SUBCAT1_Data" from the PageBuilder application. If the second site were MYCAT_SUBCAT2_, which ID# was 9998, the same thing would happen for it, resulting in [[E51:MYCAT_SUBCAT2_Data]].

Tagged:

Comments

  • Thanks for the great post, I love to see undocumented stuff revealed in the community.



    "It is really quite rare, but often enough to be an annoyance that a session variable defined in my wrapper won't be set properly"



    We use session variabled pretty heavily, and I've never run across this before. (Aside from regular ol' page wrapper confusion from working on multiple things at once.) Has anyone else found tag-set session variables to be untrustworthy?
  • It happened quite a bit during our 2013 season; in particular, it seemed that sessions variables for fr_ids were being forgotten or, if you happened to look at more than one TeamRaiser at a time, could wind up with both pages thinking you're on one or the other TeamRaiser instead of two independent ones. Been using [[S42:0:fr-id]] since then. I am familiar with only two incidents in 2015 of [[S80]] tags being empty when set by a U-tag, but as mentioned I've been trying to move away from [[S80]] at all.

Categories