User Tools

Site Tools


nupusi:nucleus:helptempvar

Nucleus CMS Template variables

Template variables.

Template variables: Overview

  • What?

Template variables largely work in exact the same way as skin variables, with the only difference that they are being used inside templates. The variables are called using <%varname%>, and include some text depending on the variable function. Some variables also have extra optional parameters.

  • Available variables

These template variables be used in the following template-parts: item header, item body, item footer, date header, date footer, morelink, editlink (The variables image, popup and media can also be used inside weblog items.)

  • Basic variables… (title, body, …)
  • Advanced variables… (include, plugin, …)

Comments-related template-parts (comments header, comments body, comments footer, one comment, two comments, comments read more, no comments, too much comments) have a different set of available variables:

  • Comments-related variables…

Template variables: Basic variables

All these variables concern the item that's currently being parsed.

Name Description
titleitem title
bodybody text
moreextended text
categoryname of the category
categorylinkraw link to the category
karmakarma score
authorlinkraw link to the author
itemlinkraw permanent link for the item
authorname of the author
smartbodyeither the body text or the extended text
morelink'read more'-link
dateFormatted date
timeFormatted time
daylinkraw link to the daily archive
commentscomments block or commentcount
itemidID of the item
blogurlURL of the blog

Template variables: Advanced variables

Name Description
authoridID of the current items author
blogidID of the blog
catidID of the category for the current item
querysearch query (if there is one)
syndicate_titleSyndicated title
syndicate_descriptionSyndicated body text
karmaposlinkraw vote link
karmaneglinkraw vote link
new'New Item!'-text
includeincludes a file, whithout parsing
parsedincludeincludes a file, parsing it
phpincludeincludes a file, parsing by PHP
pluginexecutes a plugin
editinserts an 'edit this item' link
editlinkraw 'edit item' link (links to bookmarklet)
editpopupcodejavascript code to open a popup window for editlink
skinfileincludes the correct URL for a file belonging to an imported skin
setsets a parser property
imageinline image from media library
popuppopup image from media dir
mediaother media object from media dir
relevanceIncludes the 'search hit relevance' in templates that display search results

Template variables: Comments

Name Description
bodycomment body
useruser name
useridusers URL or e-mail address
userlinka smart link to either the e-mail or URL for non members, or the member detail page for members. Note: this link already includes the <a href=“…”> and </a> tags ! (when no valid URL or e-mail is available, only the name of the member will be shown)
userlinkrawsame as above, but without the <a href.., empty when no valid URL or e-mail available
useremailthe e-mail address of the user, empty if the e-mail address was not provided by the user
userwebsitethe URL of the users website, empty if the URL was not provided by the user
memberidID of the member (0 for non-members)
commentcounttotal amount of comments for the item
commentword1 'comment', 2 'comments'
datedate on which comment was added
timetime at which comment was added
hosthost from where comment was added
ipIP-address from where comment was added
commentidID of the current comment
itemidID of the current item
itemlinklink to the detailed item page
itemtitleTitle of the current item
blogidID of the weblog
blogurlURL of the weblog
authtextthe extra text for members, empty for non members
shorta cut off version of the body, which truncates after the first line break. A link is added at the end according to the template
excerptthe body of the comment, cut at 60 characters and appended with '…'
timestamptime at which comment was added
includeincludes a file, whithout parsing
parsedincludeincludes a file, parsing it
phpincludeincludes a file, parsing by PHP
pluginexecutes a plugin
skinfileincludes the correct URL for a file belonging to an imported skin
setsets a parser property

Templatevar: author

Inserts the name of the author

  • Arguments

Optional:

  • what: Choose a type of information to be displayed:
    • name: display name (default)
    • realname: the real name of the author instead of the display name
    • id: Nucleus membet ID
    • url: URL of members website
    • email: email address of member (use of this one should be avoided)
  • Examples
<%author%>
<%author(realname)%>
<a href="<%author(url)%>"><%author%></a>

Templatevar: comments

Inserts a comments 'block'. More information about the structure of this block.

  • Arguments

Optional:

Name Contents
MaxToShowAmount of comments to show (when set, this overrides the max. comments blogsetting)
  • Examples
<%comments%>
<%comments(5)%>

Templatevar: date

Inserts a date using the date format specified in the template. Optionally, a custom date format can be given as a parameter.

  • Arguments

Optional

  • format: format to be used to format the date
  • Specials

Four special parameters are possible:

  1. rfc822: RFC822 date in local time
  2. rfc822GMT: RFC date in GMT time
  3. iso8601: ISO-8601 date (W3C Date and Time Format profile). Example: 2002-10-02T10:00:00-05:00
  4. utc: Same as iso8601, but the date is expressed in UTC, using a “Z” for the timezone indicator.
  • Examples
<%date%>
<%date(%x)%>
<%date(rfc822)%>
<%date(rfc822GMT)%>

Templatevar: edit

From within your template, you can add an 'edit item' link by using this template variable. By default, it will link to a popup-bookmarklet-window, but that behaviour can be changed through the editlink template.

  • Note: only logged in members that are allowed to edit the item will see this link. In other cases, the edit-templatevar does nothing at all.
  • Examples

An example for the item body template

<h1><%title%></h1>
<p><%body%> <%morelink%></p>
<div class="metadata">
        <%edit%> <%comments%>
</div>
  • Results in

Title

This is an item

edit - 5 comments

Insert a link to the 'edit item' bookmarklet. This can be used in the editlink template for simplicity.

  • Examples

The 'edit link'-template could look like this:

<a href="<%editlink%>"
   onclick="<%editpopupcode%>">edit</a> -

Templatevar: editpopupcode

To open a popup window for the 'edit link' window, you'll need to add some javascript code to your link. To avoid having to enter this code in the 'edit link'-template, you can insert it using the editpopupcode-templatevar.

  • Examples

See the example for the editlink templatevar

Templatevar: image

Inserts an inline image into an item body or template.

In normal use, the image-templatevar is generated automatically when adding images through the media library. You can call it from within templates too, though. Note that in this last case, the image will come out of the media dir of the current item's author.

  • Arguments
  • Required:

^ Name ^ Contents ^

filenameName of the image file (file gets)
widthWidth of the image (pixels or percentage)
heightHeight of the image
textalt-text for the image
  • Note: for the image, popup and media tags, the parameters must be separated by the '|' character, not by a comma!
  • Examples
<%image(myphoto.jpg|100|200|this is me)%>
<%image(myphoto.jpg|50%|50%|this is me, but smaller)%>

Templatevar: karma

Inserts karma votes data. Karma votes are a method to vote the 'karma' of an item. With a single click, the visitor can vote either positive or negative. The total of all these votes gives an idea of how much an item is liked by the visitors

  • Arguments

Optional:

  • what: Choose a type of information to be displayed:
    • totalscore: the total karma vote score (=amount of positive votes minus the amount of negative votes) (default)
    • pos: total number of positive votes
    • neg: total number of negative votes
    • votes: total number of votes
    • posp: percentage of votes that is positive
    • negp: percentage of votes that is negative
  • Examples
<%karma(posp)%> out of <%karma(votes)%> were positive

Templatevar: media

Inserts a media object into an item body or template.

In normal use, the media-templatevar is generated automatically when adding images through the media library. You can call it from within templates too, though. Note that in this last case, the object will come out of the media dir of the current item's author.

  • Arguments
  • Required:

^ Name ^ Contents ^

filenameName of the image file (file gets)
textdescriptive text for the media object
  • Note: for the image, popup and media tags, the parameters must be separated by the '|' character, not by a comma!
  • Examples
<%media(mysong.mp3|listen to my new song)%>

Inserts a link to the detail page for the item, as defined in the template (link to extended entry). This is empty when there is no extended part.

Note that the contents of the 'link to extended entry' templatepart is also parsed and can thus also contain templatevariables.

Templatevar: popup

Inserts a popup image into an item body or template.

In normal use, the popup-templatevar is generated automatically when adding images through the media library. You can call it from within templates too, though. Note that in this last case, the image will come out of the media dir of the current item's author.

  • Arguments
  • Required:

^ Name ^ Contents ^

filenameName of the image file (file gets)
widthWidth of the image (pixels or percentage)
heightHeight of the image
textalt-text for the image
  • Note: for the image, popup and media tags, the parameters must be separated by the '|' character, not by a comma!
  • Examples
<%popup(myphoto.jpg|100|200|this is me)%>
<%popup(myphoto.jpg|50%|50%|this is me, but smaller)%>

Templatevar: smartbody

Examines the current item and then decides to show either the body text or the expanded text.

When the extended part is empty, the body part is chosen. Otherwise the extended part is shown.

Part Empty?
BodyNoNo
ExtendedYesNo
smartbody= body part extended part
  • Examples

The body text could be interpreted as your full text, and the extended part could be interpreted as an 'introduction' or 'exerpt', which you want to show on the front page.

In the template used on the front page, you would use <%smartbody%> to insert an excerpt (if there is one), or the full text (if no excerpt). In the template for detailed items, <%body%> can then be used instead of the usual <%body%> + <%more%>, since <%body%> will contain the full item anyway.

Templatevar: syndicate_description

Inserts the body of the item, with HTML tags-stripped off, and shortened to 250 characters. When the text needs to be shortened, “…” is added at the end of the text.

This variable was originally intended for use in the XML-RSS skin that comes with Nucleus, but can also be of use in other situations.

  • Arguments
  • Optional:

^ Name ^ Contents ^

MaxCharsMaximum amount of characters to keep (defaults to 250)
  • Examples
<%syndicate_description%>
<%syndicate_description(25)%>

Templatevar: syndicate_title

Inserts the title of the item, with HTML tags-stripped off, and shortened to 100 characters. When the text needs to be shortened, “…” is added at the end of the text.

This variable was originally intended for use in the XML-RSS skin that comes with Nucleus, but can also be of use in other situations.

  • Arguments
  • Optional:

^ Name ^ Contents ^

MaxCharsMaximum amount of characters to keep (defaults to 100)
  • Examples
<%syndicate_title%>
<%syndicate_title(25)%>

Templatevar: templateitemtitle

On comments-releated templateparts, inserts the title of the associated item.

  • Arguments

Optional:

  • maxlength: When provided, makes the itemtitle behave like the syndicate_title templatevar.

Templatevar: time

Inserts a time using the time format specified in the template. Optionally, a custom time format can be given as a parameter.

  • Arguments

Optional

  • format: format to be used to format the time
  • Examples
<%time%>
<%time(%X)%>
nupusi/nucleus/helptempvar.txt · Last modified: 2008/12/06 13:56 (external edit)