Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mattstauffer/craftcms-linkhelpers


https://github.com/mattstauffer/craftcms-linkhelpers

Last synced: 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# Twig LinkHelpers for [Craft CMS](http://buildwithcraft.com/)

Add a series of Twig filters and functions for CraftCMS to add link helpers for URLs and emails.

## Installation
1. Move the `linkhelpers` directory into your `craft/plugins` directory.
2. Go to Settings > Plugins from your Craft control panel and enable the `linkHelpers` plugin

## Usage
This plugin adds several Twig filters and several Twig functions.

### Filters
#### Auto-link emails
Searches a string of text for email addresses and turns them into links.

```twig
{{ contentString | auto_link_emails }}
```
Or:
```twig
{% filter auto_link_emails %}

Content here with an email address like [email protected].


{% endfilter %}
```

Outputs:
```html

Content here with an email address like [email protected].


```

#### Auto-link URLs
Searches a string of text for URLs and turns into links.

```twig
{{ contentString | auto_link_urls }}
```
Or:
```twig
{% filter auto_link_emails %}

Content here with a URL like http://www.site.com/


{% endfilter %}
```

Outputs:
```html

Content here with a URL like http://www.site.com/


```

### Functions
#### Make a link to an email address
```twig
{{ linkEmail('[email protected]') }}
```

Outputs:

```html
[email protected]
```

#### Make a link to a URL
```twig
{{ linkUrl('http://www.site.com/') }}
```

Outputs:

```html
http://www.site.com/
```