yab_api_cache - Simple url cache for Textpattern CMS

I’ve written a simple url cache for Textpattern CMS. I use it for caching API content or shared static HTML from one source. It’s relativly straightforward.

You can grab it from GitHub. The compiled plugin version is located under the /dist folder.

yab_api_cache

Simple url cache.
Caches the outout of an url (simple GET APIs, URIs, websites etc.).
It can also be used to cache dynamic pages of the own website. Especially the ones with a lot of huge dynamic lists (but you can also use etc_cache parts of the site).

Version: 0.1.2

Table of contents

  1. Plugin requirements
  2. Configuration
  3. Tags
  4. Examples
  5. Changelog
  6. License
  7. Author contact

Plugin requirements

  • Textpattern >= 4.7.x

Configuration

Open the plugin code. The yab_api_cache function contains the configuration values. Can also be configured by tag attributes. See tag attribute for info.

Tags

yab_api_cache

This tag will output the content of a given url live or cached.

id: any valid string or empty
Default: not set
A valid string to identify the content, If not provided ist will be generated by md5 the utl attrbiute.

url: a valid string (URI)
Default: null
The URI which to be requested and shown

cached: integer|bool (1|0)
Default: true
If set to 0 (false) the requested content is live instead of the cached one.

cache_time: integer (seconds)
Default: 3600
Cache time in seconds

clear_cache: integer|bool (1|0)
Default: false
If set to 1 (truly) it will clear the entire cache.

Examples

Example: simplest

<txp:yab_api_cache url="https://exmaple.com/api/show/users" />

Shows the cached output of the given url. Renews the chache after 1 hour (3600 seconds). The md5 hash of the url is used as id.

Example: advanced

<txp:yab_api_cache id="my-api-call" url="https://exmaple.com/api/show/users" cache_time="86400" />

Shows the cached output of the given url. Renews the chache after 1 day (86400 seconds). An own id is privided

Example: no-cache

<txp:yab_api_cache id="my-api-call" url="https://exmaple.com/api/show/users" cached="0" />

Shows the live output of the given url. An own id is privided.

Example: reset

<txp:yab_api_cache clear_cache="1" />

Clears the entire cache (Empties the table).

Changelog

  • v0.1.2 – 2020-03-21
    • modified: add plugin help, public release
  • v0.1.1 – 2018-02-14
    • bugfix: id and url will be parsed
    • modifed: id not mandatory, will be created by url
  • v0.1.0 – 2017-10-29
    • initial release

Licence

This plugin is released under the GNU General Public License Version 2 and above

Author contact

yab_article_crossref - cross-reference articles in custom fields

With this small Textpattern CMS plugin you can assign an article in another articles custom field for a cross-reference. You can select the articles by an dropdown of article titles.

Download: yab_article_crossref_v0.1.txt

yab_article_crossref

Easy cross-reference an article in custom fields.

Version: 0.1

Table of contents

  1. Plugin requirements
  2. Configuration
  3. Changelog
  4. License
  5. Author contact

Plugin requirements

yab_article_crossref’s minimum requirements:

  • Textpattern 4.x

Configuration

Open the plugin code. the first function contains the configuration values:

'custom_field_nr' => ', // custom_field number containing the cross reference article ID
'sections'        => ', // sections from which we build the dropdown, comma separated
'categories'      => ' // categories from which we build the dropdown, comma separated

Changelog

  • v0.1: 2017-02-12
    • initial release

Licence

This plugin is released under the GNU General Public License Version 2 and above

Author contact

yab_cf_article_list - List and search a custom_field in admin article list

This Textpattern plugin lists a custom field in the admin article list. Additonally the article search/filter is extended with the custom field (see screenshot below).

yab_cf_article_list

Download compiled and source:
yab_cf_article_list_v0.2.tar.gz

yab_cf_article_list

List a custom_field in admin article list and search article list for this custom field.

Version: 0.2

Table of contents

  1. Plugin requirements
  2. Configuration
  3. Changelog
  4. License
  5. Author contact

Plugin requirements

Minimum requirements:

  • Textpattern 4.6.x

Configuration

Install and activate the plugin.

The function yab_cfal_config() in the plugin code contains an array with some config values:

'custom_field': Number of the custom field
Default: 1

'name_for_list': Name of the custom field in the table head and in article search.
Default: empty (The given name for this custom field will be shown.)

Changelog

  • v0.1: 2014-05-06
    • initial release
  • v0.2: 2017-02-18
    • bugfix: TXP 4.6.ready (required)

Licence

This plugin is released under the GNU General Public License Version 2 and above

Author contact

yab_copy_to_new - copy the current article content to a new one

This Textpattern plugin is a replacement for upm_savenew. It generates a button in the write tab. By clicking the button you can copy the article content to a new one.

Download compiled and source: yab_copy_to_new_v0.2.tar.gz

yab_copy_to_new

Displays a new button in article write tab to copy the current article to a new one.

Version: 0.2

Table of contents

  1. Plugin requirements
  2. Configuration
  3. Changelog
  4. License
  5. Author contact

Plugin requirements

yab_copy_to_new’s minimum requirements:

  • Textpattern 4.x
  • Modern browser capable of HTML5 sessionStorage

Configuration

Install and activate the plugin.

The following form fields will not be copied by default:

  • all of hidden type
  • an exclude array of posted day and time and the url_title
    You can modify this exclude array on your own,

The function yab_ctn_config() contains an array with some config values and a commented example of the array which places the button near the top »Create new button«.

  • 'exclude': Javascript array with field to excluded from copying
  • 'position_selector': a valid jQery selector (used by position_method)
  • 'position_method': any jQuery DOM insert method (after, prepend, append, before etc.)
  • 'class': html class applied to teh button
  • 'style': inline style attribute aplied to the button

Changelog

Install and activate the plugin.

The following form fields will not be copied by default:

  • all of hidden type
  • an exclude array of posted day and time and the url_title
    You can modify this exclude array on your own,

The function yab_ctn_config() contains an array with some config values and a commented example of the array which places the button near the top »Create new button«.

  • 'exclude': Javascript array with field to excluded from copying
  • 'position_selector': a valid jQery selector (used by position_method)
  • 'position_method': any jQuery DOM insert method (after, prepend, append, before etc.)
  • 'class': html class applied to teh button
  • 'style': inline style attribute aplied to the button

Licence

This plugin is released under the GNU General Public License Version 2 and above

Author contact

yab_remember_categories - Remembers the selected categories in write tab

This simple Textpattern plugin simply remembers the selected categories in the admin write tab while creating an article. It’s saves the values in the Browsers HTML5 localStorage.

Download compiled and source: yab_remember_categories_v0.2.tar.gz

Version: 0.2

Table of contents

  1. Plugin requirements
  2. Configuration
  3. Changelog
  4. License
  5. Author contact

Plugin requirements

yab_remember_categories’s minimum requirements:

  • Textpattern 4.x

Configuration

Install and activate the plugin. The Plugin remembers the previously selected category 1 and category 2 in write tab while creating an article by saving with HTML5 localStorage.

Changelog

  • v0.1: 2014-02-04
    • initial release
  • v0.2: 2014-02-06
    • bugfix: does now only work on article create step

Licence

This plugin is released under the GNU General Public License Version 2 and above

Author contact

yab_review_rating - A comment based rating system for Textpattern

This is (star) rating plugin for Textpattern. It’s a useful partner for yab_shop. It extends the comment system with a rating scala, so it can be used as reviews for products.

Download compiled and source: yab_review_rating_v0.6
Demo: yab_shop demo

yab_review_rating

A comment based rating system for articles.

Version: 0.6

Table of contents

  1. Plugin requirements
  2. Configuration
  3. Tags
  4. Examples
  5. Changelog
  6. License
  7. Author contact

Plugin requirements

yab_review_rating’s minimum requirements:

  • Textpattern 4.x

Configuration

Open the plugin code. the first function contains the configuration values. There is a min and a max values for the rating. Valid values are 0-255.

Tags

yab_review_rating

Place this in your comment form. It will show the rating of the current comment.
Can be used elsewhere. If not used in comment context as comments_form or recent_comments you have to fill the id attribute.

id: integer (comment id)
Default: no set
Show the rating of a comment with this ID. Useful in a non comment context.

char: a valid string
Default: no set
If empty (default) the output will be the rating number. If a char (e.g. a asterisk *) is set the output will be the n-times repeated char, where n is the rating.

yab_review_rating_input

The form element for the rating. Should be placed in the comment_form form.

type: input type (text, select, radio, number, range)
Default: text
The type of the form element for the rating. Valid value are text, select, radio, number and range.

html_id: HTML id name
Default: not set
The HTML id attribute applied to the element.

class: HTML class name
Default: not set
The HTML/CSS class attribute applied to the element.

reverse: integer|string (a non-null value)
Default: 0
If reverse is given the output of the select or radio type is displayed in reverse order.

break: breakpoint (br, empty)
Default: ‚br‘
Breakpoints für radio intputs. Can be empty or br.

default: integer
Default: not set
Preselected rating value (Could be any number between your min and max values).

yab_review_rating_average

Display the average rating for a given article.

id: integer (article id)
Default: no set
The ID of an article. If not set it must be placed in an article form (article context).

only_visible: integer|bool (1|0)
Default: 1
If set to 0 all comments (spam and moderated comments too) will be calculated.

exclude: string (a comma separated list of ratings)
Default: null
Exclude these ratings from the average rating calculation. So you can exclude ‚0‘ values for not rated articles, due 0 is the default value. Depending on your rating system setting.

default: string (Text)
Default: ‚not yet rated‘
The default text on articles without a rating.

decimals: integer
Default: 1
Define the decimal precision of the calculation and the output.

separator: string (string|empty)
Default: . (perdiod)
Choose your decimal separator. Can be empty (separator will be omitted) for HTML class friendly output.

round_to_half: string (up|down|)
Default: no net
Round to first half integer up or down or not at all. If not set the last decimal is automatically rounded up.

Examples

Example 1

Example of yab_review_rating_input in a comment_form form.

<txp:comments_error wraptag="ul" break="li" />
	<div class="message">
		<p><label for="name">Name:</label><br /><txp:comment_name_input /></p>
		<p><label for="email">Mail (not required, not visible):</label><br />
			<txp:comment_email_input /></p>
		<p><label for="yab-rr-rating">Rating</label><br />
			<txp:yab_review_rating_input html_id="yab-rr-rating" type="select" default="3" /></p>
		<p><label for="message">Review:</label><br />
			<txp:comment_message_input /></p>
		<p class="submit"><txp:comments_help /><txp:comment_preview /><txp:comment_submit /></p>
</div>

Will produce a comment form for article reviews (e.g. with yab_shop) select dropdown menu and the preselected rating value 3.

Example 2

Example of yab_review_rating in a comments form.

<h3 class="commenthead"><txp:comment_permlink>#</txp:comment_permlink> - <txp:comment_name /> wrote at <txp:comment_time />:</h3>
<span class="rating">Rating: <txp:yab_review_rating char="*" /></span>
<txp:comment_message />

Will produce a comment/review with the name, text and time of the comment and the rating with asterisks *.

Example 3

Example of yab_review_rating in a comments form.

<h3 class="commenthead"><txp:comment_permlink>#</txp:comment_permlink> - <txp:comment_name /> wrote at <txp:comment_time />:</h3>
<span class="rating rating-value-<txp:yab_review_rating />">Rating:</span>
<txp:comment_message />

Will produce a the a comment/review with the name, text and time of the comment and the rating as HTML/CSS class.

Example 4

Example yab_review_rating_average.

<txp:yab_review_rating_average id="12" exclude="0" decimals="2" separator="" round_to_half="down" />

Say the article with the ID 12 do have 3 reviews: One with a rating of 0 and two with a rating of 4 each. The output will exclude the 0 from the calculation. So only the two 4-ratings will be used 4+4 = 8÷2 = 4. Average rating is 4. But we have decimals precision of 2, so it will be 4.00. No rounding required but the separator will be ommitted: 400 will be displayed.
exclude=„0“ decimals=„2“ separator=“„ round_to_half=„down“ />

<txp:yab_review_rating_average id="12" decimals="2" separator="" round_to_half="down" />

Here we calculate an average from all reviews/ratings. Like above we have two 4 and 0-rating. So the rating is 0+4+4 = 8÷3 = 2.6666666667. Now we round to half down: 2.500000000 and use the decimal precision of 2: 2.50 and ommit the separator: 250.

Changelog

  • v0.1: 2013-12-24
    • initial release
  • v0.2: 2014-01-08
    • new: added a the tag <txp:yab_review_rating_average />
  • v0.3: 2014-01-12
    • new: added the id attribute to <txp:yab_review_rating />
    • modify: <txp:yab_review_rating /> can now be used in <txp:recent_comments />
  • v0.4: 2014-01-16
    • new: added reverse attribute to <txp:yab_review_rating_input />
    • new: added only_visible attribute to <txp:yab_review_rating_average />
    • modify: id attribute of <txp:yab_review_rating_average /> can now contain list of article ids
  • v0.5: 2017-02-10
    • TXP 4.6-ready
  • v0.6: 2017-03-09
    • bugfix: handle comment UI correctly, prevent rating resets to 0 if comment status is changed

Licence

This plugin is released under the GNU General Public License Version 2 and above

Author contact

yab_navigation_template - A Textpattern navigation template

This is a generic Textpattern template for a section based 3-level navigation and can be used in most navigation modes and styles.

With this template you can easily build complex 3-level navigations as

    * 1. Home
    * 2. Navpoint
          o 2.1 Navpoint
                + 2.1.1 Navpoint
                + 2.1.2 Navpoint
          o 2.2 Navpoint
                + 2.2.1 Navpoint
                + 2.2.2 Navpoint
          o 2.3 Navpoint
                + 2.3.1 Navpoint
                + 2.3.2 Navpoint
          o 2.4 Navpoint
          o 2.5 Navpoint
    * 3. Navpoint
          o 3.1 Navpoint
                + 3.1.1 Navpoint
                + 3.1.2 Navpoint
          o 3.2 Navpoint
                + 3.2.1 Navpoint
                + 3.2.2 Navpoint
          o 3.3 Navpoint
                + 3.3.1 Navpoint
                + 3.3.2 Navpoint
          o 3.4 Navpoint
          o 3.5 Navpoint
    * 4. Navpoint
          o 4.1 Navpoint
                + 4.1.1 Navpoint
                + 4.1.2 Navpoint
          o 4.2 Navpoint
                + 4.2.1 Navpoint
                + 4.2.2 Navpoint
          o 4.3 Navpoint
                + 4.3.1 Navpoint
                + 4.3.2 Navpoint
          o 4.4 Navpoint
          o 4.5 Navpoint
    * 5. Navpoint
    * 6. Navpoint

or a not so complex structures such as

    * 1. Home
    * 2. Navpoint
          o 2.1 Navpoint
                + 2.1.1 Navpoint
                + 2.1.2 Navpoint
    * 3. Navpoint
    * 4. Navpoint

You can grab the template here yab_navigation_template.

Some help and other information you can find on the GitHub repo of this template.

| ältere Einträge