Custom Templates

Here is a list of some custom templates you can do instead of using QARR built-in templates.

To use custom templates create a folder called qarr inside your templates directory.

Sample Templates

Look inside qarr/templates/frontend/custom for templates. So copy over what you need and configure.

File Extension

You can use html or twig extension

Display Rating

To display ratings you can use

{{ craft.qarr.displayRating(model, true) }}

Second param is optional, if set to false the function will return object rather than html markup.

Example: {% set rating = craft.qarr.displayRating(model, false) %} setting this to false will return an object

array[
   "averageRating" => 3.888888889,
   "total" => "54"
]

Template

Checks templates/qarr/rating.twig directory first, then fallsback to qarr/frontend/custom/rating.twig.

Attributes

  • averageRating - Average rating number out of 5 stars.
  • total - Total number of approved reviews

Display Reviews

To display reviews you can use

{{ craft.qarr.displayReviews(model, true) }}

Second param is optional, if set to false the function will return object rather than html markup.

Example: {% set reviews = craft.qarr.displayReviews(model, false) %} setting this to false will return an object

array[
   "averageRating" => 3.888888889,
   "reviews" => array[...],
   "total" => "54"
]

Template

Checks templates/qarr/reviews.twig directory first, then fallsback to qarr/frontend/custom/reviews.twig.

Attributes

  • reviews - Array of qarr\elements\Review elements
  • total - Total number of approved reviews

Replies

  • review.reply - Gets reply for review item
    • reply.author - Get author of reply
    • reply.dateCreated - Reply date

Display Questions

To display questions you can use

{{ craft.qarr.displayQuestions(model, true) }}

Second param is optional, if set to false the function will return object rather than html markup.

Example: {% set questions = craft.qarr.displayQuestions(model, false) %} setting this to false will return an object

array[
   "questions" => array[...],
   "total" => "54"
]

Template

Checks templates/qarr/questions.twig directory first, then fallsback to qarr/frontend/custom/questions.twig.

Attributes

  • questions - Array of qarr\elements\Question elements
  • total - Total number of approved questions

Answers

  • question.answers - Array of qarr\model\Answer models for specific question
    • answer - Returns answer string
    • anonymous - Checks if user requested to be posted anonymously
    • author - Gets author object craft\elements\User
    • abuse - Check is answer has been marked as abusive
    • dateCreated - Answer date