Skip to content

erikreagan/hivelogic-ee-shrimp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Shrimp

Shrimp is an ExpressionEngine plugin that provides URL shortening functionality. Shrimp is different from similar plugins in that it provides features like customizable link generation, access to the shortened URL for your own custom links, smart meta tags which hide themselves on non-entry pages, access to the relative URL (without the protocol or domain), and more, without any unnecessary database access.

Shrimp transforms long URLs like this:

http://site.com/weblog/entries/some-article-title

into shortened URLs like this:

http://site.com/u/123

Shrimp then provides redirection from the shortened URL to the long URL through the use of a simple, one-line template.

It is recommended that you remove the “index.php” from your URLs as described here (although Shrimp will work either way).

Compatibility

As of version 1.5 Shrimp is compatible with both ExpressionEngine 1.x and 2.x branches

Installation

For EE 1.x

  • Copy the shrimp/pi.shrimp.php file to your system/plugins directory

For EE 2.x

  • Copy the shrimp directory to your system/expressionengine/third_party directory

USAGE

Integrating Shrimp into your ExpressionEngine website is a straight forward process.

Create a new template group for the redirection. Give the group a short name, such as “u”, in order to keep the URL as small as possible (Shrimp will actually assume the default template group name “u” if you don’t specify one).

Paste the following line into the index template in the new template group. You must replace “weblog/entries” in the example below with the name of your individual entry view template:

{exp:shrimp:redirect template="weblog/entries" entry_id="{segment_2}"}

Add the following line to the HEAD block of your entry view template, replacing the template value with the name of the template group you created in the first step (or omit it and Shrimp will use “u”):

{exp:shrimp:meta_tag template="u" entry_id="{entry_id}"}

Display the short link on your site, within an {exp:weblog:entries} tag block. Shrimp can generate a full <a href> tag with a customizable title like this:

{exp:shrimp:link title="Short URL" template="u" entry_id="{entry_id}"}

This will generate an <a href> tag like this:

<a href="http://site.com/u/123" title="Short URL">Short URL</a>

You can specify anything you want for the link title, such as the entry’s title:

{exp:shrimp:link title="{title}" template="u" entry_id="{entry_id}"}

This will generate an <a href> tag like this:

<a href="http://site.com/u/123" title="My Entry Title">My Entry Title</a>

If you’d prefer to create your own custom links, you can access the shortened URL directly for use in your own links or for display using the “permalink” method like this:

{exp:shrimp:permalink template="u" entry_id="{entry_id}"}

This will output just the shortened permalink without the <a href> tag, like this:

http://site.com/u/123

If you just want to access the shortened path without the protocol (http://) and site name, you can call the “relative_url” method, like this:

{exp:shrimp:relative_url template="u" entry_id="{entry_id}"}

This will return just the path of the short URL, like this:

/u/123

About

ExpressionEngine plugin to create short URLs.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Languages