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

https://github.com/nystudio107/pathtools

DEPRECATED This twig plugin for the Craft CMS brings convenient path & url manipulation functions & filters to your Twig templates.
https://github.com/nystudio107/pathtools

craft-plugin craftcms path

Last synced: 4 months ago
JSON representation

DEPRECATED This twig plugin for the Craft CMS brings convenient path & url manipulation functions & filters to your Twig templates.

Awesome Lists containing this project

README

          

[![No Maintenance Intended](http://unmaintained.tech/badge.svg)](http://unmaintained.tech/)

# DEPRECATED

This Craft CMS 2.x plugin is no longer supported, but it is fully functional, and you may continue to use it as you see fit. The license also allows you to fork it and make changes as needed for legacy support reasons.

The Craft CMS 3.x version of this plugin can be found here: [craft-pathtools](https://github.com/nystudio107/craft-pathtools) and can also be installed via the Craft Plugin Store in the Craft CP.

# PathTools twig plugin for Craft

This twig plugin for the Craft CMS brings convenient path & url manipulation functions & filters to your Twig templates.

Related: [PathTools for Craft 3.x](https://github.com/nystudio107/craft3-pathtools)

## Installation

To install PathTools, follow these steps:

1. Download & unzip the file and place the `pathtools` directory into your `craft/plugins` directory
2. -OR- do a `git clone https://github.com/khalwat/pathtools.git` directly into your `craft/plugins` folder. You can then update it with `git pull`
3. Install plugin in the Craft Control Panel under Settings > Plugins
4. The plugin folder should be named `pathtools` for Craft to see it. GitHub recently started appending `-master` (the branch name) to the name of the folder for zip file downloads.

## Usage

All of the functionality offered by PathTools can be used either as a filter, e.g.:

```
{{ myAsset.url | basename }}
```

Or as a function, e.g.:

```
{% set myBaseName = basename(myAsset.url) %}
```
## php Wrapper Functions
### pathinfo
Wrapper for the php pathinfo() function --
### basename
Wrapper for the php basename() function --
### dirname
Wrapper for the php dirname() function --
### parse_url
Wrapper for the php parse_url() function --
### parse_str
Wrapper for the php parse_str() function --
## Utility Functions
### swap_extension
Can be passed either a path or a url, and it will return the path or url with the filename extension changed, e.g.:

```

```
For ``myAsset.url`` = ``http://www.coolvids.com/content/vids/MyCoolVid.mp4`` the output would be:

```

```

### swap_directory
Can be passed either a path or a url, and it will return the path or url with the directory path changed, e.g.:

```

```
For ``myAsset.url`` = ``http://www.coolvids.com/not/here/rock.pdf`` the output would be:

```

```
### append_suffix
Can be passed either a path or a url, and it will return the path or url with the suffix appended to the filename, e.g.:

```

```
For ``myAsset.url`` = ``http://www.coolvids.com/img/ux/search.png`` the output would be:

```

```

## Changelog

### 1.0.2 -- 2016.08.04

* [Added] Added the parse_str() function
* [Improved] Updated the README.md

### 1.0.1 -- 2015.11.23

* [Added] Added support for Craft 2.5 new plugin features
* [Improved] Updated the README.md

### 1.0.0 -- 1/2/2015

* Initial release