Editing HTML templates

All the templates you can edit to change the layout of your UserVoice portal, widget or email are written in a templating language called Liquid. Before you attempt to edit any templates of your UserVoice accounts we highly recommend you check out the Liquid wiki and familiarize yourself with the various tags and filters at your disposal.

The other thing you’ll need to know to make the most of Liquid templates is what objects are available and what attributes those objects have. Thus we’ve included below a list of what objects are available, depending on the context, and what attributes those objects have.

Examples

You can see a simple of example of how to use we use these Objects in the default footer template for your UserVoice portal which has this line:

1
<a href="{{ site.path }}" class='site-frontpage-link'>{{ site.title }}</a>

The site object is available in every template but some objects, such as current_suggestion, aren’t so you’ll want to wrap your code like so:

1
2
3
{% if current_suggestion %}
  <p>{{ current_suggestion.title }}</p>
{% endif %}

The tables below lay out what Objects are available in what templates.

Template Objects

Portal Templates

Variable Name Description
site Basic information on your UserVoice site (x.uservoice.com). Present in all templates
current_user Only present if the user is signed in
current_forum Forum that is being viewed. Present on all /forums/[id]* pages (including category & suggestion pages)
current_category Category within a Forum that is being viewed. Only present on /forums/[id]/category pages
current_suggestion Suggestion being viewed. Only present on /forums/[id]/suggestions pages
current_topic Knowledgebase Topic that is being viewed. Only present on /topics/[id]* pages (including pages for individual articles)
current_article Article being viewed. Only present on /articles/[id] pages
current_time Time.now
forums All forums available to the current user (logged in or not)
locale Language the page is being rendered in (ex: ‘en’ is English, ‘fr’ is French, etc; See translate.uservoice.com for the full set of available locales). Useful if you want to create a blocks of text for specific languages.

Ticket Email Templates

Variable Name Description
site Basic information on your UserVoice site (x.uservoice.com). Present in all templates.
current_ticket Current Ticket
current_message Current message (be it from user or agent)
current_user User object for message recipient (ticket contact or someone CC’d)
current_agent User object for agent replying

Object Reference

User [current_user]

Attribute Type Notes
id int
name string
url string
avatar_url string
email string
title string
guid string
karma_score
created_at datetime
updated_at datetime

Site [site]

Attribute Type Notes
id int
name string
title string
url string
path string
host string
body_text text Plaintext version of welcome message
body_html text HTML version of welcome message
is_white_labelled boolean
kudos_enabled boolean
feedback_ui_enabled boolean
knowledgebase_ui_enabled boolean
support_ui_enabled boolean
has_logo boolean
logo_url string
link_color string
background_color string
primary_color string
default_forum object
has_forums boolean
forums_count int
forums array
recently_updated_suggestions array
has_topics boolean
topics_count int
topics array
has_articles boolean
articles_count int
articles array
organization object
all_article_path string

Organization

Attribute Type Notes
name string
url string

Forum [current_forum]

Attribute Type Notes
id int
name string
url string
path string
body_text text Plaintext version of welcome message
body_html text HTML version of welcome message
prompt string
votes_allowed int
is_private boolean
is_closed boolean
created_at datetime
updated_at datetime
has_categories boolean
categories array
categories_count int
has_suggestions boolean
suggestions array
suggestions_count int
recently_updated_suggestions array

Category [current_category]

Attribute Type Notes
id int
name string
created_at datetime
updated_at datetime
forum object
suggestions array
suggestions_count int
has_suggestions boolean

Suggestion [current_suggestion]

Attribute Type Notes
id int
title string
url string
path string
forum object
category object
created_at datetime
updated_at datetime
status_name string merge, spam, deleted, ticketed, [status.name]
status_class string uvStyle-status-#{status_name}

Topic [current_topic]

Attribute Type Notes
id int
name string
url string
path string
articles_count int
has_articles boolean
articles array

Article [current_article]

Attribute Type Notes
id int
title string
url string
path string
topic object

Ticket [current_ticket]

Attribute Type Notes
id int
subject string
number int

Message [current_message]

Attribute Type Notes
id int
incognito_mode? boolean
is_admin_response boolean
kudos_url string

Didn’t find what you’re looking for?

Check out the UserVoice Help Center for more documentation.

Explore the Help Center