Helpers

Introduction

DOCman provides a number of template helpers to help you further customize your layouts.

Tags

DOCman comes with a native tagging feature. The tags helper provides two methods title and link to help you render tags.

Render Tag Titles

This is an example of how you can render a tag title:

<?= translate('Tagged in: {tag}', ['tag' => helper('tags.title', ['tag' => $tag_slug])]) ?>

The title method returns a tag’s title as a human readable string value. This method accepts an array with the following key:

  • tag: a unique slug value associated with the tag

A document may have one or many tags. You can render them as a list of links. Here is an example:

<?= translate('Tagged in {tags}', array('tags' => helper('tags.link', [
    'entity' => $document, 'menu' => $menu
]))); ?>

The tags method extracts the tags associated with the document entity and retuns them as a concatenated series of html anchor tags. This method accepts an array with the following keys:

  • entity: document entity object
  • menu: the active menu item object

Note: we are passing the active menu to make sure that the tag link redirects a user to the same menu item.

Need Help?

Let our developers personally assist you. You can ask development related questions in our Support Center. Only for Business or Agency subscribers.