Plugin mem_filter
Category: Projects
Posted:
This plugin allows filters and other simple string calculations to be applied to arbitraty text. It also allows for arbitrary text to be stored and used multiple times on the page without duplicating tags.
file:
mem_filter.txt [12.83kB]
Category: Textpattern
download: 520
Textpattern plugins can be downloaded from Bitbucket
Textpattern Filter Plug-in
This plugin allows filters and other simple string calculations to be applied to arbitraty text. It also allows for arbitrary text to be stored and used multiple times on the page without duplicating tags.
Updates
- Version 0.2:
- Multiple filters can be used for each filter tag. Filter names should be specified as an ordered comma separated list.
- Added filter rel_nofollow. This tags all external links with the rel=”nofollow” attribute.
- Added filter external_links. This tags all external links by appending ”[domainname.com]” after the link. It will also set the link’s title to “domainname.com” if a title is not found.
Requirements:
- Textpattern v1.0rc1 (or newer)
Client Plug-in Tags:
- mem_set
- mem_get
- mem_filter
mem_set
This tag parses and the enclosed text and saves it with the specified name. The enclosed text is not outputted to the user.
Attributes:
- name—(required) The name that will be used to recall the saved text.
- parse—(optional) Specifies whether or not to parse the enclosed text before saving the value. Default is 1.
Examples:
<txp:mem_set name="some_text">This is some text.</txp:mem_set>
mem_get
This tag recalls text that was saved with mem_set.
Attributes:
- name—(required) The name that contains the desired text block.
Examples:
<txp:mem_get name="some_text" />
mem_filter
This tag allows for a the enclosing text (and tags) to be processed by a filter or hash function. The enclosed text can optionally be parsed before the filter is applied. This tag is designed to be used in conjunction with mem_get and mem_set, so that the content can displayed filtered and in its original format.
Attributes:
- name—(optional) A comma separated list of filter names that will be applied in order to the enclosed text.
- parse—(optional) Specifies whether or not to parse the enclosed text before applying the filter. Default is 1.
Supported Filter Names:
- base64_encode—Encodes the data with base64. see
- base64_decode—Decodes base64 data. see
- crc32—Generates the cyclic redundancy checksum polynomial of 32-bit lengths of the data. see
- crypt—This returns an encrypted string using the standard Unix DES-based encryption algorithm or alternative algorithms that may be available on the system. see
- external_links—This will locate all external links and append its domain name after the link. If a title is not set, then it will be set to the domain name. E.g. http://www.php.net/ [php.net]
- htmlspecialchars—see
- lcase—Converts the text to lowercase. see
- md5—Calculates the md5 hash of the string. see
- rel_nofollow—Modifies external link tags by adding the rel=”nofollow” attribute. see
- rot13—Encodes the text with rot13. see
- sha1—Calculates the sha1 hash of the string. see
- shuffle—Shuffles the characters in the string. see
- ucase—Converts the text to uppercase. see
- ucfirst—Capitalizes the first letter of the string. see
- ucwords—Converts The First Letter Of Each Word To Uppercase. see
- urlencode—Converts all non-alphanumeric characters except -_. to a percent (%) sign followed by two hex digits and spaces encoded as plus (+) signs. see
- urldecode—Decodes any %## encoding in the given string. see
- uudecode—Decodes a uuencoded string. see
- uuencode—Encodes a string using the uuencode algorithm. see
- wordcount—Calculates the number of words. see
Examples:
- <txp:mem_set name="o" parse="0"><txp:body /></txp:mem_set>
This tag <txp:mem_filter name="o" parse="1" name="htmlspecialchars"><txp:mem_get name="o" /></txp:mem_filter>
will output this "<txp:mem_get name="o" />"