Shortcut 3.x

Legacy documentation for Shortcut 3.x.

Shortcut:Shortcuts template tag

The Shortcut:Shortcuts tag lets you display a list of Shortcut data, such as the Shortcut URL's and the total number of times the shortcut URL was accessed.

{exp:shortcut:shortcuts} content {/exp:shortcut:shortcuts}

Parameters

The following parameters are available for use:

shortcut_id=

shortcut_id="2"

This parameter can be used to retrieve and isolate Shortcut data from a specific Shortcut. Just specify the unique ID.

shortcut=

shortcut="xSc2"

This parameter can be used to retrieve and isolate Shortcut data from a specific Shortcut. Just specify the shortcut segment.

limit=

limit="10"

You can limit the number of Shortcuts returned by using this parameter.

offset=

offset="5"

You can offset the Shortcut results returned by using this parameter.

orderby=

orderby="hits"

This parameter allows you to set a specific order for your Shortcut listings. The default order is shortcut_id. For multiple ordering, separate each item with a pipe character. Other available orders are:

  • hits which will return shortcuts ordered by their total hits.
  • full_url which will return shortcuts ordered alphabetically by the full URL associated with the Shortcut URL.
  • shortcut which will return shortcuts ordered alphabetically by the Shortcut URL.
  • entry_date which is the date the shortcut was added to the system.
  • edit_date which is the date that the shortcut was last edited/modified.
  • custom_shortcut which will return shortcut data (y or n) based on whether they use a custom shortcut suffix or an autogenerated one.

sort=

sort="asc"

This parameter allows you to control the output sort order. Available methods are ascending (asc) or descending (desc) order. For multiple ordering, separate each item with a pipe character. Default is asc.

paginate=

paginate="bottom"

Pagination works just like it does in the Channel:Entries tag. When specified, and used in conjunction with the shortcut:paginate variable pair, pagination will display. Refer to Channel:Entries tag documentation for more information.

Variables

The following variables are available for use:

shortcut

{shortcut}

This variable returns the shortcut URL suffix (example: xSc2).

shortcut:absolute_results

{shortcut:absolute_results}

This variable will return the absolute total amount of shortcut results. This includes all shortcuts of all pages when pagination is used.

shortcut:count

{shortcut:count}

This variable outputs the display order number for each result in the list of shortcuts (within the page, if using pagination).

shortcut:custom_shortcut

{shortcut:custom_shortcut}

This variable will return y if the shortcut was created using a custom suffix and n if the shortcut was automatically created.

shortcut:date

{shortcut:date format="%F %j, %Y at %g:%i %a"}

This variable will display the date the shortcut was created. This variable should be formatted using standard EE date formatting.

shortcut:edit_date

{shortcut:edit_date format="%F %j, %Y at %g:%i %a"}

This variable will display the date the shortcut was last edited. If the shortcut has not been edited, this variable will not output anything. This variable should be formatted using standard EE date formatting.

shortcut:full_url

{shortcut:full_url}

This variable returns the full URL associated with the Shortcut URL (example: http://www.solspace.com/docs/shortcut/).

shortcut:hits

{shortcut:hits}

This variable returns the total hits for a shortcut (the total number of times the shortcut URL was accessed).

shortcut:id

{shortcut:id}

This variable returns the unique ID of the shortcut.

shortcut:total_results

{shortcut:total_results}

This variable outputs the total amount of shortcuts in the results (within the page, if using pagination). You would typically use this in a conditional statement.

shortcut:url

{shortcut:url}

This variable returns the complete shortcut URL (example: http://solspa.ce/xSc2).

Variable Pairs

Most of the variable pairs available in the Channel:Entries loop are available here. Additionally, the following variable pairs are available for use:

shortcut:paginate

{shortcut:paginate}
    <li>
        Page {shortcut:current_page} of
        {shortcut:total_pages} pages &nbsp;
        {shortcut:pagination_links}
    </li>
{/shortcut:paginate}

OR

{shortcut:paginate}
<ul class="pagination">
    {shortcut:pagination_links}
        {first_page}
            <li><a href="{pagination_url}">First</a></li>
        {/first_page}
        {previous_page}
            <li><a href="{pagination_url}">&laquo; Previous</a></li>
        {/previous_page}
        {page}
            <li{if current_page} class="active"{/if}><a href="{pagination_url}">{pagination_page_number}</a></li>
        {/page}
        {next_page}
            <li><a href="{pagination_url}">Next &raquo;</a></li>
        {/next_page}
        {last_page}
            <li><a href="{pagination_url}">Last</a></li>
        {/last_page}
    {/shortcut:pagination_links}
</ul>
{/shortcut:paginate}

Pagination is available for this tag and works just like regular EE pagination, but each variable/variable pair is prepended with shortcut: (except for any variables and variable pairs inside of the shortcut:pagination_links variable pair). Used in conjunction with the paginate parameter.

Conditionals

In addition to most conditionals available in the Channel:Entries tag, the following conditionals are available for use:

shortcut:no_results

{if shortcut:no_results}
    Sorry, no results were found.
{/if}

This conditional displays it's contents when there are no results found.

Examples

The below is a basic example of how you show Shortcuts ordered by the number of hits:

{exp:shortcut:shortcuts
    orderby="hits" sort="desc"
    limit="10" paginate="bottom"
}

    {if shortcut:no_results}
        Sorry, no shortcuts found.
    {/if}

    {if shortcut:count == 1}<ul>{/if}
        <li>
            <a href="{shortcut:url}">{shortcut:url}</a>
            (accessed {shortcut:hits} times)
        </li>
    {if shortcut:count == shortcut:total_results}</ul>{/if}

    {shortcut:paginate}
        Page {shortcut:current_page} of {shortcut:total_pages} pages
        {shortcut:pagination_links}
    {/shortcut:paginate}

{/exp:shortcut:shortcuts}