PHPackages                             cara-tm/pat\_if\_amp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. cara-tm/pat\_if\_amp

ActiveTextpattern-plugin[Utility &amp; Helpers](/categories/utility)

cara-tm/pat\_if\_amp
====================

Google AMP for Textpattern CMS.

v0.3.7(8y ago)4341GPL-2.0PHP

Since Jul 4Pushed 6y ago4 watchersCompare

[ Source](https://github.com/cara-tm/pat_if_amp)[ Packagist](https://packagist.org/packages/cara-tm/pat_if_amp)[ Docs](https://github.com/cara-tm/pat_if_amp)[ RSS](/packages/cara-tm-pat-if-amp/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

pat\_if\_amp
============

[](#pat_if_amp)

[Download](https://github.com/cara-tm/pat_if_amp/releases) | [Packagist](https://packagist.org/packages/cara-tm/pat_if_amp)

AMP pages for [Textpattern CMS](http://textpattern.io/).

This conditional tag examines the URL of the current page and determines if the URL ends in ‘amp.’ This allows for a custom page to be rendered using the standards for Google’s Accelerated Mobile Pages (AMP) project.

Links
-----

[](#links)

- [GitHub Code Repository](https://github.com/cara-tm/pat_if_amp)
- [Download](https://github.com/cara-tm/mkp_if_amp/blob/master/pat_if_amp_v3.5_zip.txt)
- [Demo Site for initial plugin](http://ampdemo.cmsstyles.com/)

Don’t forget to check out my other plugin that’s also Google AMP compatible: [pat\_article\_social](https://github.com/cara-tm/pat_article_social)

Note
----

[](#note)

Since TXP 4.7+ and its new features, you can choose to use build-in tags solution instead of this plugin. Read more about from [this forum post by Oleg](https://forum.textpattern.com/viewtopic.php?pid=320549#p320549) (don’t forget to add a TXP variable on the fly for further usages within you website):

```

    AMP page

    regular page

```

Installing
----------

[](#installing)

Using [Composer](https://getcomposer.org):

```
$ composer require cara-tm/pat_if_amp:*
```

Or download the latest version of the plugin from [the GitHub project page](https://github.com/cara-tm/pat_if_amp/releases), paste the code into the Textpattern Plugins administration panel, install and enable the plugin.

pat\_if\_amp
------------

[](#pat_if_amp-1)

### Attributes

[](#attributes)

- `url` *string* (optional): The location (URL) of the website. Default: `hu` (website URL as set in the Textpattern preferences panel).
- `subdomain` *string* (optional): Sets the subdomain name of where to redirect to. Default: `amp`.
- `permlink` *boolean* (optional): if set to `0` (false) the redirection for the same article’s URL mode within the subdomain will be not made. Default: `1` (true).

### Example

[](#example)

Place code similar to below within your individual article template header, so that the AMP page can be properly detected:

```

```

Place something similar to below within your individual article template to display the alternative formatting:

```

```

Textpattern variable usage
--------------------------

[](#textpattern-variable-usage)

A `` with a true/false value (`1` or `0`) is automatically generated, for testing when this is an AMP context or not.

### Usage

[](#usage)

```

    AMP context

    Normal context

```

### Example

[](#example-1)

```

    ...Do some AMP things...
    AMP Category 1 Link

    ...Do some normal (non-AMP) things...

```

This example concerns categories, use kind of the same model for `pages` and/or `archives`.

pat\_amp\_sanitize
------------------

[](#pat_amp_sanitize)

A tag to render article text content without any inline styles. To use as a drop-in replacement of the standard Textpattern `` tag and/or `` tag.

### Attributes

[](#attributes-1)

- `content` *string* (optional): choose either `body` or `excerpt` article content to sanitize. Default: `body`.

### Usage

[](#usage-1)

In an article Form context:

```

```

pat\_amp\_redirect
------------------

[](#pat_amp_redirect)

A simple tag for web redirection to a subdomain name. Same behaviour as used in *The Guardian* website. Must be used with a mobiles detection script (i.e. adi\_mobile plugin). Some web designers could choose to use a subdomain for their mobiles websites (may be not recommended, but the official AMP Blog is located in a subdomain, see: ). In this case, **the Textpattern multi-sites capacities makes things easier**.

**Note:** Doesn’t work on local server installations, only on live servers.

### Usage

[](#usage-2)

```

```

**Good advice**: Copy the `config.php` file of the main site into the subdomain configuration folder in order to share the same database. So, all articles written by the Copy Editors will be sent automatically to the ‘AMP powered website’ from only one Textpattern administration interface attached to the ‘normal’ website. But designers have a separate and cleaner space to build their AMP pages.

### Attributes

[](#attributes-2)

- `url` *string* (optional): The location (URL) of the website. Default: `hu` (website URL as set in the Textpattern preferences panel).
- `subdomain` *string* (optional): Sets the subdomain name of where to redirect to. Default: `amp`.
- `permlink` *boolean* (optional): Choose to redirect the same individual article’s title URL within the subdomain. Default: `0` (false).

### Example

[](#example-2)

```

```

In this case, if your main domain is `example.com`, it redirects to the `amp.example.com` subdomain and uses the same individual article’s URL from the main domain.

### Acknowledgments

[](#acknowledgments)

Many thanks to [Phil Wareham](http://www.designhive.com/contact/phil-wareham) who tidied up this plugin code and its help file.
Thank you to [Michael K. Pate](https://github.com/michaelkpate), for its original idea, who accepted to distribute my entire rewriting code as a ‘pat’ prefixed plugin.

[![](https://raw.githubusercontent.com/cara-tm/pat_if_amp/master/amp-project-textpattern-cms-mention.png)](https://raw.githubusercontent.com/cara-tm/pat_if_amp/master/amp-project-textpattern-cms-mention.png)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 73% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~97 days

Total

4

Last Release

2992d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/61045?v=4)[Patrick LEFEVRE](/maintainers/cara-tm)[@cara-tm](https://github.com/cara-tm)

---

Top Contributors

[![cara-tm](https://avatars.githubusercontent.com/u/61045?v=4)](https://github.com/cara-tm "cara-tm (73 commits)")[![philwareham](https://avatars.githubusercontent.com/u/413665?v=4)](https://github.com/philwareham "philwareham (19 commits)")[![michaelkpate](https://avatars.githubusercontent.com/u/313786?v=4)](https://github.com/michaelkpate "michaelkpate (8 commits)")

---

Tags

accelerated-mobile-pagesampgoogle-amptextpatterntextpattern-pluginpluginampamp-htmltextpatterngoogle-amp

### Embed Badge

![Health badge](/badges/cara-tm-pat-if-amp/health.svg)

```
[![Health](https://phpackages.com/badges/cara-tm-pat-if-amp/health.svg)](https://phpackages.com/packages/cara-tm-pat-if-amp)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
