THCNET Macro System
The thcnet macro system is used to specify formatting of dynamic information within the template files. When the template files are processed, the macro codes are replaced with context sensitive information, such as %%user%% is replaced with the current user name, the name of the user who wrote the message being displayed, or the name of the current user record, depending on where the macro was used.
In addition, you can limit or customize the display of macros by using a switches in conjunction with the macro, in the format:
%%macro[,switch[,switch[...]]]%%
Combinations of switches can be used to further limit their display. For example:
%%user,l,!u,|am,"User is %s.",!"Hello."%%
would display the user name provided the current user was logged in, was not the user name of the current context (for example in the display of an article not written by the user), or the user had an access level of moderator or above, and if so display the text in quotes placing the macro output where the %s is located, or if it's not true, display the text in quotes with the leading !. Given that all that was true, the output would be:
User is Krux.
or
Hello.
You can take this a step further by grouping blocks of text and displaying them based on access levels. Such as in this example:
%%blockstart,!l%% %%formlogin%% Login:<br> %%inputname%%<br> Password:<br> %%inputpassword%%<br> %%submitlogin%% %%formend%% %%blockend,!l%% %%blockstart,l%% Hello %%user%%,<br> You have logged in %%logins%% times.<br> %%blockstart,aa%% You are an administrator.<br> <a href="%%admin%%">Admin</a> %%blockend,aa%% %%blockend,l%%
If the user is not logged in, it displays a login form. Otherwise it greets the user with their name, displays how many times they have logged in, and if they are an administrator, lets them know that fact plus gives them a link to the admin section.
one note about using blocks is that the blockstart and blockend statements must be on a line of their own. This wouldn't work:
%%blockstart,l%% Hello %%user%% %%blockend,l%%
The above example would *NOT* be displayed correctly.
You can however have multiple non-block macros on the same line without any problems, such as this:
<a href="%%userinfo%%">%%user%%</a>
or even, though a bit cluttered:
%%user%%%%datetime%%%%email%%
As you can see there is a lot of flexibility and power with what you can do with the macro system.
Reference
Syntax:
%%macro[,switch[,switch[...]]]%%
Switches:
|
OR. used with a switch to specify if something is a logical OR, ie |l, OR user is logged in.
!
NOT. used with a switch to specify if something is a logical NOT, ie !l, user is NOT logged in.
a###
Access level ### or greater. (note this is current users access level, not item user's access level)
ap
Access level can post or greater.
am
Access level moderator or greater.
aa
Access level admin or greater.
as
Access level sysop or greater.
b########
Msgboard name
d
There are deleted messages.
e
Encryption enabled
f
Form sub block. Only used in the userlist function.
g#
Current User flag letter #. (note this is current users flag settings, not item user's flag settings)
h#
Item User flag letter #. (note this is item user's flag settings, defaults to current user when not in item)
i###
Item User number ###.
j"dateformat"
Use Alternate datetime format (used only on datetime macro)
l
User is Logged in.
m
There are messages pending moderation.
n###
Function parameter #### (i.e. #### is the parameter after the comma.)
n
Function parameter is not empty
p
There are private messages waiting. (not implemented yet)
r
Recursion level
s########
Section name
t
Search Engine Robot
u###
User number ###.
u
User same as current context.
x
Site currently locked.
"text"
Text displayed after macro is displayed.
"text %s text"
Formatted text display, replaces %s in string with macro output.
"function"
Function output. Used only with the %%content%% macro to allow detailed display of information. ie. "section=article&start=0&count=1&nonav=1" would display only the very latest article without *next and *prev navigation links at the bottom.
Macros
Block Macros
%%blockstart%%
use: general start of block.
%%blockend%%
use: general end of block.
note: blockstart and blockend macros must be on a line by themselves.
general macros
%%section%%
use: general
displays the title of the current section.
%%title%%
use: article
displays the title of the current article.
%%score%%
use: article
displays the score of the current article.
%%divuserscore%%
use: article
div tag with style based on the user score for the current article.
%%userscore%%
use: article
span with style and output for user score for the current article.
%%inputscore%%
use: article
input for users to rank the current article.
%%inputscorecomment%%
use: article
input for users comment on rank for the current article.
%%basename%%
use: article
class: title
displays the current message base name.
%%new%%
use: article
display if article is new and link to next new article.
%%email%%
use: general, article, user, userlist
display users email address.
%%maskemail%%
use: general, article, user, userlist
display users masked email address.
%%userinfo%%
use: general, article, userlist
display url to display users profile.
%%ip%%
use: article
displays posting IP address of current article.
%%user%%
use: general, article, userlist, user
displays user name for current context.
%%currentuser%%
use: general
displays user name for current logged in user.
%%usercount%%
use: userlist
displays login count for users online.
%%datetime%%
use: article, general
displays date and time of current article or system time.
%%newdatetime%%
use: article, general
displays date of the newest article in a thread.
%%reply%%
use: article
displays url to reply from article or display entire thread from main.
%%replyid%%
use: article
displays ID of current article.
%%parentid%%
use: article
displays ID of parent article.
%%replycount%%
use: article
displays number of replys to current thread.
%%articlemenu%%
use: article
displays a generic menu to reply/edit/delete current article.
%%baseimage%%
use: article
displays messagebase image for first article in a thread.
%%baseimageurl%%
use: article
displays messagebase image for first article in a thread.
%%text%%
use: article
displays the article message body.
%%online%%
use: article, userlist, user
displays current online status.
%%lastactive%%
use: article, userlist, user
displays last online date and time.
%%access%%
use: article, userlist, user, general
displays user access level.
%%messages%%
use: userlist, user
display count of user's messages.
%%logins%%
use: userlist, user
display count of user's logins.
%%personalinfo1%%
use: userlist, user
display user's personal info field 1.
%%personalinfo2%%
use: userlist, user
display user's personal info field 2.
%%personalinfo3%%
use: userlist, user
display user's personal info field 3.
%%signature%%
use: userlist, user
display user's signature field.
%%comment%%
use: userlist, user
display user's admin comment field.
%%userlist%%
use: general
displays url to display the user list.
%%baseurl%%
use: general
displays base url.
%%url%%
use: general
displays url with session info.
%%post%%
use: general
displays url to post a new message.
%%messagelist%%
use: general, user, userlist
displays url to display a list of messages for user.
%%admin%%
use: general
displays url to admin screen.
%%updatelastread%%
use: general, user
displays url to mark viewed messages as read.
%%resetlastreadurl%%
use: general, user
displays url to mark all messages as read.
%%resetlastread%%
use: general, user
displays html link to mark viewed messages as read.
%%dumplastread%%
use: general, user
displays html link to drop all viewed message tracking.
%%archive%%
use: general
displays url to display historical archive of message threads.
%%inputsearchname%%
use: general, post, user
class: inputname
displays form input for username.
%%inputname%%
use: general, post, user
class: inputname
displays form input for username.
%%inputpostname%%
use: post
class: inputname
displays form input to override username when posting.
%%inputpostdate%%
use: post
class: inputdate
displays form input to override post date when posting.
%%inputemail%%
use: general, user
class: inputemail
displays form input for email address.
%%inputpassword%%
use: general
class: inputpassword
displays form input for password.
%%inputsetpassword%%
use: general, user
class: inputpassword
displays form input for password with confirmation.
%%inputpersonalinfo1%%
use: user
class: userinfo
displays form input for user personal info field 1.
%%inputpersonalinfo2%%
use: user
class: userinfo
displays form input for user personal info field 2.
%%inputpersonalinfo3%%
use: user
class: userinfo
displays form input for user personal info field 3.
%%signatureform%%
use: user
displays user signature subform.
%%inputsignature%%
use: user
class: userinfo
displays form input for user signature.
%%inputdeletesignature%%
use: user
class: checkbox
displays form checkbox to delete users signature.
%%inputcomment%%
use: user
class: userinfo
displays form input for user admin comment.
%%inputtemplate%%
use: user
displays form input for selecting the display theme.
%%inputquoting%%
use: user
displays form input for user quoting method.
%%inputpreview%%
use: user
displays form input for user preview method.
%%inputthreading%%
use: user
displays form input for user threading method.
%%inputthreadsortorder%%
use: user
displays form input for user thread sort method.
%%inputminmessages%%
use: user
class: count
displays form input for user minimum number of messages to display on main page.
%%inputmindays%%
use: user
class: count
displays form input for user minimum days of messages to display on main page.
%%inputmaxdays%%
use: user
class: count
displays form input for user maximum days of messages to display on main page.
%%inputaccess%%
use: user
class: count
displays form input for user access level.
%%inputflags%%
use: user
displays form input for user access flags.
%%submituser%%
use: user
class: submit
displays submit buttom for user edit form.
%%submitaddsignature%%
use: user
class: submit
displays add buttom for user signature edit form.
%%inputdeleteusermessages%%
use: user
class: checkbox
displays form checkbox to delete users messages when deleting user.
%%submitdeleteuser%%
use: user
class: submit
displays submit buttom to delete user.
%%stickylogin%%
use: general
class: checkbox
displays checkbox to remember user login.
%%submitlogin%%
use: general
class: submit
displays submit button to login.
%%submitapply%%
use: general
class: submit
displays submit button to apply as a new user.
%%formend%%
use: general
displays close form tag.
%%formlogin%%
use: general
displays open form tag for user login form.
%%formpost%%
use: post
displays open form tag for post message form.
%%submitpost%%
use: post
class: submit
displays submit button to post message.
%%submitpreview%%
use: post
class: submit
displays submit button to preview message.
%%submitcancel%%
use: post
class: submit
displays submit button to cancel message.
%%logout%%
use: general
displays url to logout.
%%login%%
use: general
displays url to login.
%%searchresults%%
use: general
displays the search results.
%%searchwarning%%
use: general
displays the search results.
%%search%%
use: general
displays url to advanced search.
%%formsearch%%
use: general
displays open form tag for search form.
%%inputcount%%
use: general
class: count
displays form input for count number.
%%inputsearch%%
use: general
class: search
displays form input for search.
%%inputsearchbody%%
use: general
class: search
displays form input for search on body.
%%inputsearchtitle%%
use: general
class: search
displays form input for search on title.
%%inputsearchboard%%
use: general
displays form input for search on message board.
%%inputsearchstartdate%%
use: general
class: inputdate
displays form input for search after start date.
%%inputsearchenddate%%
use: general
class: inputdate
displays form input for search before end date.
%%inputsearchorder%%
use: general
displays form input for search order.
%%submitsearch%%
use: general
class: submit
displays submit button for search.
%%inputboard%%
use: post
displays input selection of message board.
%%inputtitle%%
use: post
class: inputTitle
displays form input of message title.
%%inputbody%%
use: post
class: inputBody
displays form input of message body.
%%usersonline%%
use: general
class: menu
displays count of users online with link to online user listing.
%%deleted%%
use: general
displays number of deleted messages.
%%moderate%%
use: general
displays number of messages pending moderation.
%%info%%
use: general
displays system information messages.
%%version%%
use: general
displays current thcnet version.
%%pagetime%%
use: general
displays time to render page.
%%baseselector%%
use: general
displays message base selector.
%%navigation%%
use: general
displays navigation selector.
%%instantmsg%%
use: userlist, user
displays url to instant message a user.
%%templatepath%%
use: general
location of files.
%%include%%
use: general
include a template file.
%%includephp%%
use: general
include a php file and displays contents of $output variable.
%%setflag%%
use: general
set thcnet user flag in option text.
%%clearflag%%
use: general
clear thcnet user flag in option text.
%%setenv%%
use: general
set thcnet environment variables.
%%content%%
use: general
displays main content.
