Caucus Macros

Last revised 08/16/09

The Caucus "macro" capability is a simple "macro expansion" language that is embedded into CML, the "Caucus Markup Language". See the $mac_define() function in the Caucus Reference Manual for general information on defining Macros.

There is a large set of pre-defined macros included with Caucus. They fall into three major categories:

  1. Simple macros that ordinary users can enter into their own items and responses.
  2. More complex macros intended for power users, organizers, or managers, to define or extend aspects of the user interface.
  3. Internal macros used in the CML pages to implement the user interface. These are really being used as extensions to the CML language itself, and should not be seen or used by ordinary or power users.

The macros in each major category are also divided by overall purpose into sub-categories, although the division is not always obvious.

Any arguments inside []'s are optional and may be left out.  Don't actually type the []'s.

Some definitions of macro arguments follow:


  1. Ordinary User Macros
    1. Text Manipulation Macros
      Most of these were meant for the "plain text" editor, and are not needed for the "rich text" editor (aka RTE).

      %bold (text)

      %b(text)

      %tt (text)

      %blockquote (text)

      %italic(text)

      %i(text)

      %big(text)

      %small(text)

      %sub(text)

      %sup(text)

      %strike(text)

      %under(text)

      %mono(text)

      %color (colorname text)

      %bullet(text)
      Indented "bulleted" paragraph. 

      %ol(n text)
      Indented numbered (N) paragraph. 

    2. "Go to" macros

      %response (rnum)
      Link to response rnum in the current item. 

      %item (inum [rnum])
      Link to item inum, optionally to specific response rnum

      %itemtitle(inum)
      Link to item inum, but show the title of the item as the link text. 

      %conference (conf_name [inum [rnum [hover text]]])
      Link to conference conf_name, optionally specifying item inum, response rnum.  If 'hover text' is supplied, mousing-over the link will show hover_text as a DHTML pop-over.  In that case, inum=0 means just the conference, no item. 

      %createItem(linktext)
      If user can create an item in the current conference, display link to "create an item" page with linktext
    3. People

      %person(userid [opt link text])
      Link pops-up window with info about userid

  2. Power Users & Managers
    1. "Go to" location - advanced
      Use these in responses or other text to provide links to other conferences or locations.

      %url (actual_url, text of link)
      Pop-up link to an external URL actual_url

      %protocolOf(url)
      Extract just the protocol name (http or https) from url, even if url has already been expanded into a clickable link by the richtext editor. 

      %urlparams (actual_url, windowparams, text of link)
      Like %url, but you may specify the javascript-style window opening parameters in windowparams

      %last(conf_name inum optional_text)
      Link to last response in conference conf_num item inum

      %conf_is_allowed (conf_name text)
      Evaluates to text if current user is allowed in conf_name

      %conf_has_new (conf_name text)
      Evaluates to text if there is new material in conf_name

      %conf_link (conf_name text)
      Evaluates to a link with text, that goes to conf_name

      %conf_url (conf_name)
      Evaluates to full URL for conference conf_name.  Use "/caucus/conf_name" instead unless contraindicated. 

      %conf_item_url (conf_name item)
      Evaluates to full URL for conference conf_name, item.  Use "/caucus/conf_name/item instead unless contraindicated. 

      %conf_item_link (confname item linktext)
      Evaluates to a link with linktext, that goes to conference confname, item item

      %conf_name_with_new (conf_name text)
      "Convenience macro", combines other macros to show text link to conference conf_name (if allowed), with a new icon (if anything is new). 

      %TMN_CONF_with_new (conf_name text)
      Same as %conf_name_with_new(). 

      %conference_with_new (conf_name [optional text])
      Link to conference conf_name, but with the new icon if anything is new.  If 'optional text' is supplied, shows that as link text instead of conference name

      %conf_file_url (conf_name user item resp filename)
      Full URL for file filename uploaded by user into conf_name, item, resp

      %conf_has_new_br (conf_name text)
      Evaluates to text (with a line break at the end) if conf_name has new material. 

      %conf_link_br (conf_name_br text)
      Evaluates to a link (with a line break at the end) text to conf_name

      %conf_name_with_new_br (conf_name text)
      "Convenience macro", combines other macros to show link with text to conference conf_name (if allowed), with a new icon (if anything is new) along with a line break at the end of each line. 

      %anyConfHasNew(conf1 conf2 ...)
      Evaluate to the new icon if any of the confs 'conf1', 'conf2', etc.  have new material. 

      %countNewInCnum(cnum)
      Evaluates to the number of items with new material in conference cnum

      %center(text)
      Link (with text) to Caucus Center

      %readrange (startitem enditem link_text)
      Link to read items startitem thru enditem in current conference. 

      %conf_has_no_new (conf_name text)
      Evaluates to text if there is no new material for this user in conf_name

      %purchaseGroupMembership(groupType groupName paypalAccount price link-text)
      Pops open a window that allows the current user to purchase, through PayPal, membership in the specified Caucus group on this site.  For example, %purchaseGroupMembership(Caucus4 myGroup roth@caucuscare.com 1.00 Buy Access) will display a link with text "Buy Access".  The price is $1.00, and completing the purchase will automatically add the current user to the "System" group "myGroup".  If the user already has membership in that group, the link will NOT appear. 

    2. Interface Storage Conference
      Every Caucus "interface" has a special conference that is used to help define the look and feel of the interface. (E.g. for interface CC51, the conference is called interface_storage_cc51.) This conference only appears to Caucus managers, it is otherwise invisible to regular users. The macros below reference items in this conference.

      %ifs_page_link (item resp text)
      ("InterFace Storage PAGE LINK").  Evaluates to a link with text, that goes to ifspage.cml (shows a response as a single "resource" page), item:resp from the current "Interface Storage" conference. 

      %ifs_popup (item resp [width=nnn] [height=nnn] text)
      Evaluates to a link with text, that pops-up a new page, with contents of IFS (item, resp) -- and nothing else! If the optional width= and height= parameters appear (in that order!), they control the size of the pop-up window. 

      %ifs_resp (item [resp])
      ("InterFace Storage RESPonse") Evaluates to text of current Interface Storage conference item:resp, interpreted as CML. 
    3. People - Advanced

      %personpop(userid)
      Like %person(), but always the pop-up, never the edit-my-own-page.  No (uid) after the name, either. 

      %person_noclick (userid [text])
      Evaluates to a "do-nothing" link with either the person's name, or else text, as text.  Clicking on the link does nothing. 

      %mailto (email_address Name)
      Evaluates to a "mailto:" link using email_address, and Name as the link text.  Clicking on this link will automatically open most user's email client, preparing to send email to email_address

      %aim(handle)
      hot link to AIM instant messenger for handle

      %onnow_check()
      Calculate list of users "on now".  Use this immediately before calling %onnow_link(). 

      %onnow_link()
      link to page showing table of current users

      %onnow_user(uid)
      shows "(now)" if uid is on now.  (Must call %onnow_check() once beforehand in page)

      %peoplelist(grouptype groupname $quote(fieldList) title)
      Display a list of all the people in grouptype, groupnamefieldlist is a space-separated list of the fields to be displayed, including: lname, fname, userid, laston, email.  To turn off display of a field, prefix with "-", i.e.  "-email" prevents displaying the email column.  title is the title displayed at the top of the list. 

      %peoplelistURL(grouptype groupname $quote(fieldList))
      Same as %peoplelist(), except it evaluates to a URL to a page that just lists the people. 

      %peoplegallery(grouptype groupname all width title)
      Display a rectangular "gallery" of the people in grouptype, groupname.  If all is 1, display everyone in the group.  If 0, display only those people who have pictures.  width is the numeric value of the width of the page, e.g.  5 means show 5 people "across". 

      %groupMap (groupType groupName text)
      Evaluates to a link (with text) that pops-up a Google Maps page, showing the location of everyone in groupType, groupName

      %itemMap (itemLabels zoom text)
      Evaluates to a link (with text) that pops-up a Google Maps page, showing the location from which the items in itemLabels were written.  ItemLabels is a comma-separated list or range of item labels.  Zoom is the Google-maps zoom factor, typically 3-18.  0 defaults to a reasonable value. 

      %itemMapEmbed (itemLabels zoom width height)
      Embeds a Google Maps page (in the current page), showing the location from which the items in itemLabels were written.  ItemLabels is a comma-separated list or range of item labels.  Zoom is the Google-maps zoom factor, typically 3-18.  0 defaults to a reasonable value.  Width is the width of the map in pixels.  Height is the height of the map in pixels. 

      %itemMapFrame (itemLabels zoom width height)
      Embeds a Google Maps page (in the current page), showing the location from which the items in itemLabels were written.  ItemLabels is a comma-separated list or range of item labels.  Zoom is the Google-maps zoom factor, typically 3-18.  0 defaults to a reasonable value.  Width is the width of the map in pixels.  Height is the height of the map in pixels. 

      %addUser2GroupOnClick (groupType groupName ifsItem text)
      Evaluates to a link with text to IFS page ifsItem.  When user clicks through to the page, Caucus adds their userids to group groupType groupName
    4. Images and Videos

      %imagelink (imageURL targetURL [width [height]])
      Evaluates to an image-link: it shows the image at imageURL, clicking on the image pops-up a window showing the page at targetURL.  The new window may be set to open with width and height (in pixels). 

      %image(URL [width height [alt_text]])
      Simply displays the image at URL, scaled to width and height, and with optional alt_text (what you see if image display is turned off, or if you hover over the image). 

      %icon_new()
      Displays the "new" icon. 

      %photo (userid [options])
      Evaluates to a clickable image link of user userid, clicking pops-up the person page for useridOptions are HTML image options, such as "height=xx", etc. 

      %picture(userid/filename)
      Displays image in Caucus site's public_html/LIB/PICTURES/userid/filename.  Convenience macro for statically-supplied images. 

      %swfVideo (source width height)
      Show an SWF ("flash") video embedded in the current window.  source is the URL of the video width and height are specified in # of pixels. 
    5. My Conferences

      %myGroupConfs (groupType groupName showHeader text...)
      Display a "My Conferences"-like list of conferences (with columns for new material) that belong to group (groupType, groupName).  If showHeader=1, display the column headers.  Text is the optional "lead-in text" that appears at the head of the list of conferences. 
    6. Integration With External Tools

      %watchitoo(meetingId [width height])
      Shows a box width by height pixels that connects to the Watchitoo.com video/chat/meeting server.  The Caucus configuration file (swebd.conf) must have defined the config parameters watchitooVendorId and watchitooAccessToken, as supplied by Watchitoo. 

  3. Internal Macros
    1. Windows

      %js_open_win (name [opener])
      Javascript to open a new window.  if opener is not empty, use opener of current window to determine proper size of new window. 
       
         Property          Values           Means 
           toolbar           1, 0 (on, off)   (back,forward buttons, etc) 
           location          1, 0             (current URL field) 
           directories       1, 0             (directory buttons - ugh) 
           status            1, 0             (status line at bottom) 
           menubar           1, 0             (menu bar - file, edit, view etc.) 
           scrollbars        1, 0             (enables scroll bars when needed) 
           resizable         1, 0             (resize windows? note spelling!) 
           width             pixels           (initial width of window) 
           height            pixels           (initial height of window) 
      

      %js_open_ann()
      Open announcements window. 

      %userxs(popup defaultx)
      X Size of pop-up window.  (User vars are xs_@1, ys_@1.)

      %userys(popup defaulty)
      Y Size of pop-up window.  (User vars are xs_@1, ys_@1.)

      %to_parent (url)
      ilist.i Redirect links to parent window if $(target_switch) is true.  Usage: <A HREF=%to_parent(url)>

      %_new_target_window(newx, newy)
      (nee "%target" in 4.0).  Opens a new window to be used as a target for some URL.  If possible, makes new window 40 pixels less in x and y than the current window.  For old browsers, the new window size is newx x newy pixels.  Typically used in an >A HREF> tag to put the target URL in a new window, as in: <A HREF="some_url" %_new_target_window(x, y)>

      %_target_fromcau(newx, newy)
      Opens a window fromcau to be used as a target for some URL.  If possible, makes new window 40 pixels less in x and y than the current window.  For old browsers, the new window size is newx x newy pixels.  Typically used with richtext editor URLs, as in: <a href="someurl" target="fromcau" onClick="%_target_fromcau(newx,newy);">

      %iframe (url pure [optwidth [optheight [options]]])
      Display URL in an Iframe.  optWidth is optional width, optHeight is optional height (pixels assumed unless other units given).  Pure is always 1 (reserved for expansion).  Other options may be specified, see http://www.w3schools.com/TAGS/tag_iframe.asp

    2. Miscellaneous I

      %leave(URL)
      Dummy macro, just expands to argument(s).  Provided so that display of new user registration "layout" page appears to work like the real thing but doesn't terminate Caucus process. 

      %location(url)
      Replaces all uses of "Location:" directive to go to another CML file.  Acts as an effective work-around for the IE 4 bug (see http://gamgee.acad.emich.edu/~roth/ie_location.html).  If the URL has no #fragment, or is not IE 4, %location just spits out the appropriate "Location:" directive.  Otherwise, it produces a tiny HTML page that sets location.href to the proper url. 

      %chk(X)
      Macro for cus_en*.cml.  If X is in table CHK, output a "CHECKED" tag (for <INPUT TYPE=checkbox...> stuff). 

      %en_var(user conf var)
      Get value of e-mail notification variable. 

      %set_en_var(user conf var values...)
      Set value of e-mail notification variable. 

      %bad_email_address (x)
      Bad if not empty and (no @, no ., has any of ";|&,<>()", or > 1 words).  Could be made smarter... 

      %nooplink(text)
      Make a link with text that does nothing.  Used for the last entry in the location (compass) bar. 

      %backlink(text)
      Make a link with text that does a "BACK". 

    3. MSET, MPUSH, MPOP.
      Handle "m" values (m_cnum, m_inum, m_rnum)
      that are used in all of the %liburl2() derived macros for uploaded files.

      %mset (c i r) Set values of m_cnum, m_inum, m_rnum that are
      used in %liburl2 macros (when they are outside of their proper item)

      %clear(stackName)

      %push (stackName value)

      %pop (stackName)

      %top (stackName)

      %mpush (c i r) Save current m values on a stack, then set new ones.

      %mpop() Pop m values off of stack.

      %_caucus_url(cnum inum rnum)
      (nee "%special" in 4.0).  Translate 'http:/caucus/...' so-called "special" URLs into URLs that reference the appropriate CML pages.  Note! inum is the item label, not the item_id. 

      http:/caucus -> (goes to) the Caucus Center
      http:/caucus/conf -> conference home page of conf
      http:/caucus/conf/item -> conference conf, item # item
      http:/caucus/conf/item:r -> conf item item, response r.

    4. File upload macros.
      These are internal macros that Caucus automatically generates when files are uploaded. The user is not supposed to use them, but they will see them briefly in the text of their response as they are writing the response. The "2" versions (liburl2, libimg2, etc.) are for 4.1+ and assume an "rdir" (item/response sub directory) that is keyed to the particular item and response numbers where the file was uploaded.

      %liburl2 (userid rdir file) URL of file in library
      Build link to uploaded file in Caucus LIB directory.  File is referenced by userid, filename file, and "magic" code rdir: 1=response, 0=body of item, qp=attached to quiz, ap=attached to assignment. 

      %liburl_at (conf item resp file)
      URL of file in library in another conference conf, item item

      %libimg(userid file)
      IMG file in library (deprecated)

      %libimg2(userid rdir file [options])
      IMG file in library

      %libimg2r(userid rdir file [options])
      IMG file in library, right-aligned. 

      %libimg_at (conf item resp file [options])

      %libgallery(userid rdir file)

      %liblink(userid file)
      link to file in library (deprecated)

      %liblink2(userid rdir file)
      Link to file in library

      %libname(userid file name)
      Named link to file in library (deprecated)

      %libname2(userid rdir file name)
      Named link to file in library

    5. MISC

      %telnet (host_address Name)

      %re_text (cnum id rnum)
      Evaluates to raw text of item id (internal item id), response rnum

    6. Files and Filesafes

      %files (name text)
      Not sure what this is. 

      %filesafe (name [text])
      Evaluates to link to filesafe file name.  Use text for link text if supplied.  (What the heck should name be?)

      %filesafes (prefix)
      List all viewable filesafes beginning with prefix; if no prefix, list all filesafes. 

      %filesafesec (name section [text])
      Evaluates to a link (with optional text) to a file safe section, for filesafe name, section section

      %filesafesecurl (name section)
      Evaluates to full URL to filesafe name, section

      %filesafefile (name section file)
      Evaluates to a link to file in filesafe name, section

      %filesafefileurl (name section file)
      Evaluates to full URL to file in filesafe name, section

      %filesafethumb (name section filesmall filebig [width height])
      Evaluates to a clickable link that is (presumably) a small image file filesmall in filesafe name, section.  Clicking on the link pops up a new window containing filebig from the same filesafe section.  Width and height are optional arguments to specify the new window size. 

    7. MISC II

      %login_gme (url text)
      Example macro for how to integrate login with another web application (in this case GroupMind Express).  See login_gme.cml for more info.  Caller must supply login form submission page as url, text as text of link. 

      %preinc(x)
      Pre-increment x.  Like C "++x"

      %displayed_conf_name(cnum)
      Evaluates to displayed form of conference name for conference cnum

      %interface (dir [text]) Link to start using interface 'dir'.
      Evaluates to a clickable link (with optional text) that goes to (??), switching the user to interface dir

      %mainwindow (url text)
      Used in a pop-up window, displays a link with text that redirects the main (opening) window to url

      %flashchat(text)
      Pop-up link to a Flashcoms chat room (that is implicitly tied to the current conference), with linktext text.  Automatically signs user in, with current Caucus userid. 

    8. Gradebook etc.
      Macros added to support "gradebook", "assignments", and "symbols button" and related features.

      %is_class(cnum)
      Is cnum a "class" conference?

      %supports_class()
      Evaluates to 1 if this install support "class" (course) conferences, else 0. 

      %tab([x])
      Evaluates to auto-incremented 'tabindex="n"', for use in defining tabbing order for <input> objects.  %tab(x) starts sequence over again at x.  %tab() increments current value of variable tabindex. 

      %fName (uid)
      "Firstname" of userid uid

      %lName (uid)
      "Lastname" of userid uid

      %per_lname(uid)

      %per_name(uid)
      Full name of user uid, replaces old $per_name(). 

      %my_name()
      Full name of this user, replaces old $my_name(). 

      %my_phone()
      Phone number of current user, replaces old $my_phone(). 

      %my_intro()
      Introductory text of current user, replaces old $my_intro(). 

      %per_phone(uid)
      Phone number of user uid, replaces old $per_phone(). 

      %per_laston(uid)
      Date/time user uid was last on Caucus, replaces old $per_laston(). 

      %assign(key text)
      Evaluates to a link with text, to assignment key

    9. Math symbol utility macros
      For some reason, class="x" where x has text-decoration: none doesn't work in IE6.

      %mathsym (symbolname [expand])
      ??

      %sym()
      ??

      %mathimg (imgblue [imgblack])
      ??

      %courselist(options)
      Display list of courses.  See courselist.i for options

      %no_such_conf (cnum)
      ??

      %is_instructor()
      Evaluates to 1 if current user is a manager, or an organizer or instructor of any conf?

      %listpeople (separator userid [userid2...])
      ??

      %people(center linktext)
      ??

      %instructors (cnum)
      List of userids of "instructors" of course conference cnum, in the order they appear

      %emImgSep (prop)
      ??

      %emFileSep (prop)
      ??

      %urcregnums()
      Sorted list of field numbers of REG urc field variables, e.g.  REG_CC44/reg_1 is "1", etc. 

      %onnow_options()
      Static list of default options allowed for %onnow() (Makes it easy to expand by putting definition in local_macros.)

      %intro(text)
      Evaluates to "useful" expansion of text, frequently used to format the "intro" text of a user. 

      %taskPriority(n)
      Translates raw priority number n to text (Low, medium, etc.)

      %mgr_in_group (userid mgrgroups...)
      Same as $mgr_in_group, but automatically includes systemAllPrivileges (just to save us typing!)

      %hasUpper (string)
      Evaluates to 1 if string contains any upper-case chars, else 0. 

      %access(cnum [userid])
      Returns access level granted to userid in conference cnum.  Replaces old calls to $cl_access().  "Optional" access values are returned as 0!

      %lowname(cnum)
      Evaluates to lower-case version of conference name of cnum

      %homepage()
      ??

      %briefintro()
      ??

      %item_lastresp(item_id)
      ??

      %itemsUnder (cnum itemId)

      %item_title(item_id)
      Evaluates to title of item item_id

      %acceptTerms(item)
      ??

    10. Quizzes

      %quiz_summary(itemlabel)
      Link to a quiz summary, item number (label) itemlabel

      %quiz_problem_summary(itemlabel)
      ??
    11. Filters and general text manipulation

      %digit4(number)
      Pad number with leading zeroes, to make a 4 digit number. 

      %digit8(number)
      Pad number with leading zeroes, to make an 8 digit number. 

      %word_remove (n list)
      Evaluates to a list of words, but with word number n removed. 

      %word_insert (n word list)
      Evaluates to a list of words, but with word inserted at position n

      %reducedChars(text)
      Evaluates to text, with everything translated to lower case, and blanks and non-printable chars removed. 

      %makeLegal (str)
      Evaluates to str, translated to a legal CDATA form that HTML form name= fields will accept. 

      %safename(text)
      Evaluates to text, but with non-printing chars (including blanks) replaced with "_". 

      %striplink(string) "Strip" the <A HREF=...>url</a> away from the
      start of string, leaving just the "url" part, and anything following after the <A HREF>...</A>.  Frequently used in other macros that take a URL as an argument, but may (due to the quirky nature of the richtext editor) find that they are getting a full <A HREF> tag set instead. 

      %stripquotes(text)
      Strips leading and trailing double quotes from text

      %nbsp(text) translate all blanks in 'text' into  's.

      %trimtext (chars text)
      Display 1st chars of text.  If not all of text is displayed, add a "..." on the end to indicate text was trimmed. 

      %rtrim (text)
      "Right trim" text, i.e.  remove all trailing blanks.  Note: we need to remove trailing newline generated by $includecml()!

      %tripletOf(cnum word)
      Evaluate to the conf/itemId/response triplet of "word", which can be an item:response label, or the keyword "last", or anything that $item_parse() can handle. 
    12. SQL

      %sql(query)
      Simple execution of SQL query.  For non-SELECTs only.  We keep _q, _h in case we ever need to debug this. 

      %sql1row(query)
      Simple execution of SQL query.  For one-rows SELECTs only.  We keep _q, _h in case we ever need to debug this. 
    13. Date & Time

      %epoch_of (x)
      Returns epoch time.  X can either be an epoch time number, or a date string (such as produced by $dateof()).  Used when forcing a possibly unknown format into epoch time.  Returns 0 if X is empty. 

      %datetz ( date | time)
      Translate a 2-word date (e.g.  the output from $dateof()) or a 1-word time (e.g.  the output from $time()) into the $dateof() format for the current timezone, as defined by $(timezonehrs).  E.g.  if the server local time is EST, and $(timezonehrs) is set to -3, then %datetz (23-MAY-2003 11:00) becomes "23-MAY-2003 8:00". 

      %yyyymmddOf (date)
      Convert common date formats to yyyy-mm-dd. 

      %epochOfyyyy (date)
      Converts yyyy-mm-dd date to epoch times. 

      %dateOfyyyy (date)
      Convert yyyy-mm-dd date to...  ?

      %monthDayYear (date)
      Convert yyyy-mm-dd date to "Mon dd, yyyy". 

      %monthDayYearHour(date)
      Convert yyyy-mm-dd hh:mm:ss date to "Mon dd, yyyy hh:mm". 

      %monthDayYearHourTZ(date)
      Adjust a "yyyy-mm-dd hh:mm" date by the number of hours in $(timezonehrs), and then display it as "Mon dd, yyyy hh:mm". 

      %monthDay(date)
      Evaluate to day of month(?) of date

      %monthDayHour(datetime)
      ??

      %openElgg (elggUrl link-text)
      Experimental!  Displays a link.  Clicking on the link opens a new window, and automatically (SSO) logs in to Elgg, with the Caucus userid -- but it only works if the Caucus userid is an OpenId(!!).  elggUrl is the URL of Elgg installation, minus the leading http://

      %frameElgg (elggUrl topSizeInPixels link-text)
      Experimental!  Displays a link.  Clicking on the link goes to a page with the usual Caucus toolbar in a top frame, and Elgg in the lower frame.  elggUrl is the URL of Elgg installation, minus the leading http://.  topSizeInPixels is the size of the top frame.