To create new wiki account, please join us on #znc at Libera.Chat and ask admins to create a wiki account for you. You can say thanks to spambots for this inconvenience.

ZNC Templating: Difference between revisions

From ZNC
Jump to navigation Jump to search
>Jakoch
initial draft for templating guide
 
>Jakoch
 
(3 intermediate revisions by 2 users not shown)
Line 99: Line 99:
{|
{|
|colspan="3"|
|colspan="3"|
=====Set by webmodules.cpp - CWebSock::SetVars()=====
=====Set by /znc/src/webmodules.cpp - CWebSock::SetVars()=====
|-
|-
|'''Variable name'''
|'''Variable name'''
Line 111: Line 111:
|SessionIP
|SessionIP
|GetRemoteIP()
|GetRemoteIP()
|Prints users IP
|Prints users IP .
|-  
|-  
|Tag
|Tag
|CZNC::GetTag()
|CZNC::GetTag()
|Prints ZNC Version and Website Link
|Prints ZNC Version and Website Link.
|-  
|-  
|Version
|Version
|CZNC::GetVersion()
|CZNC::GetVersion()
|Prints ZNC Version Number
|Prints ZNC Version Number.
|-
|-
|SkinName
|SkinName
|GetSkinName()
|GetSkinName()
|Prints name of the active theme
|Prints name of the active theme.
|-
|-
|CSRF_Check
|CSRF_Check
|GetCSRFCheck()
|GetCSRFCheck()
|...
|Prints a md5 hash of the user session id. You won't really need this... Just use <nowiki><? INC _csrf_check.tmpl ?> inside <form>s</nowiki> which use POST
|-
|-
|IsAdmin
|IsAdmin
|GetSession()->IsAdmin()
|Is true, when the user is administrator.
|-
|LoggedIn
|LoggedIn
|bool
|IsLoggedIn()
|Is true, when the user is logged in.
|}
|}

Latest revision as of 08:17, 30 March 2012

ZNC Templating

These are my notes on templating for ZNC. I (jakoch) made them while creating the "znc-ation" skin. I had to figure the stuff out by reading the C source or asking around. Its a work in progress and others should/may contribute and enhance the pieces of information provided here. I hope it saves you some time, when doing templates for ZNC.

All template commands are placed in shorttags: <? ... ?>.

How to print a variable on template side?

<? VAR variablename ?>

Comparisons and Expressions

There are the following comparisons and expressions available:

IF AND (&&)

<? IF varA && varB ?> BOOLEAN AND <? ENDIF ?>

IF OR (||)

<? IF varA || varB ?> BOOLEAN OR <? ENDIF ?>

IF NOT (!)

Example usage on form input fields: <? IF !variablename ?> disabled="disabled" <? ENDIF ?>

More Expressions

!=

==

>=

<=

>

<

Template Commands

INC - Includes a file <? INC myfile.tmp ?>

SETOPTION

ADDROW

SET

JOIN

ESC - Escape

<? VAR VARIABLE ESC=ASCII ?>

SETBLOCK ENDSETBLOCK

EXPAND

LT - <?

GT - ?>

BREAK

CONTINUE

EXIT

DEBUG

LOOP ENDLOOP

REVERSE

SORT ASC DESC

REM - Comment inside Templates ENDREM

IF ELSE ENDIF

LOOP

Documentation of variables assigned to the template

Set by /znc/src/webmodules.cpp - CWebSock::SetVars()
Variable name Getter for the data Description
SessionUser GetUser() Prints username
SessionIP GetRemoteIP() Prints users IP .
Tag CZNC::GetTag() Prints ZNC Version and Website Link.
Version CZNC::GetVersion() Prints ZNC Version Number.
SkinName GetSkinName() Prints name of the active theme.
CSRF_Check GetCSRFCheck() Prints a md5 hash of the user session id. You won't really need this... Just use <? INC _csrf_check.tmpl ?> inside <form>s which use POST
IsAdmin GetSession()->IsAdmin() Is true, when the user is administrator.
LoggedIn IsLoggedIn() Is true, when the user is logged in.