Source

ee-shrimp /

Filename Size Date modified Message
25 B
3.1 KB
7.6 KB

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:

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

into shortened URLs like this:

<pre>
http://site.com/u/123
</pre>

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).

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:

<pre>
{exp:shrimp:redirect template=“weblog/entries” entry_id=”{segment_2}”}
</pre>

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”):

<pre>
{exp:shrimp:meta_tag template=“u” entry_id=”{entry_id}”}
</pre>

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:

<pre>
{exp:shrimp:link title=“Short URL” template=“u” entry_id=”{entry_id}”}
</pre>

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

<pre>
<a href=“http://site.com/u/123”; title=“Short URL”>Short URL</a>
</pre>

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

<pre>
{exp:shrimp:link title=”{title}” template=“u” entry_id=”{entry_id}”}
</pre>

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

<pre>
<a href=“http://site.com/u/123”; title=“My Entry Title”>My Entry Title</a>
</pre>

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:

<pre>
{exp:shrimp:permalink template=“u” entry_id=”{entry_id}”}
</pre>

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

<pre>
http://site.com/u/123
</pre>

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:

<pre>
{exp:shrimp:relative_url template=“u” entry_id=”{entry_id}”}
</pre>

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

<pre>
/u/123
</pre>

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.