	<h1>rah_metas</h1>

	<p>A tiny <abbr title="Search engine optimization"><span class="caps">SEO</span></abbr>- and meta-tool for <a href="http://www.textpattern.com">Textpattern <span class="caps">CMS</span>.</a> Build descriptions, simple meta info, rel links and prevent double content.</p>

	<ul>
		<li>Version: 1.3</li>
		<li>Updated: 2010/05/23 9:30 AM <span class="caps">UTC</span></li>
	</ul>

	<h3>Table of Contents</h3>

	<ul>
		<li><a href="#intro-and-description">Intro and description</a></li>
		<li><a href="#list-of-features">List of features</a></li>
		<li><a href="#requirements">Requirements</a></li>
		<li><a href="#installation-and-usage">Installation and usage</a></li>
		<li><a href="#attributes">Attributes</a></li>
		<li><a href="#example">Examples</a></li>
		<li><a href="#changelog">Changelog</a></li>
		<li><a href="#known-issues">Known issues</a></li>
		<li><a href="#thanks-to">Thanks to</a></li>
	</ul>

	<h3 id="intro-and-description">Intro and description</h3>

	<p>A Textpattern plugin used for <abbr title="Search engine optimization"><span class="caps">SEO</span></abbr>. The plugin includes basic <span class="caps">SEO</span> tools, from semi-automatic metainformation generation to useful redirections that prevent double content as rah_metas is also able redirect requested messy urls to cleans, leaving no space for the double content fault.</p>

	<h3 id="list-of-features">List of features</h3>

	<ul>
		<li><strong>Outputs automatic metadescriptions</strong> from article&#8217;s body, excerpt or custom field.</li>
		<li><strong>Limits and customizes the automatic metadescription</strong> by word or character limit, strips all <span class="caps">XHTML</span> and invalid characters.</li>
		<li><strong>Redirects messy urls to clean ones, if cleans are in use</strong>. In example, <code>?id=xx</code> and <code>?s=xx</code> would be redirect to the correct place, preventing possible double content.</li>
		<li><strong>Outputs other useful meta</strong> as author, description and language.</li>
	</ul>

	<h3 id="requirements">Requirements</h3>

	<p>Minimum requirements:</p>

	<ul>
		<li><span class="caps">PHP</span> 4.4.0+</li>
		<li>Textpattern 4.0.4+</li>
	</ul>

	<p>Recommended:</p>

	<ul>
		<li><span class="caps">PHP</span> 5.1.2+</li>
		<li>Textpattern 4.0.8+</li>
	</ul>

	<h3 id="installation-and-usage">Installation and usage</h3>

	<p>The general behavior stands: paste plugin code to the plugin installer textarea and run the automatic setup. Then just activate the plugin and you are ready to use new tags that plugin includes like others.</p>

	<p>For usage, basically just put <code>&lt;txp:rah_metas /&gt;</code>-tag with wanted attributes to inside your site&#8217;s <code>&lt;head&gt;</code>-tags. As the plugin&#8217;s tag outputs metainformation, and meta-tags, it shouldn&#8217;t be used outside <code>&lt;head&gt;</code>-tags.</p>

	<h3 id="attributes">Attributes</h3>

	<p>The tag is <code>&lt;txp:rah_metas /&gt;</code> and attributes for it follow. Default value <code>&quot;&quot;</code> means that the attribute is unset and defaultly non-used.</p>

	<p><strong>imagetoolbar</strong><br />
To block an browser&#8217;s imagetoolbar. Allowed attributes <code>true</code> or <code>false</code>.<br />
Example: <code>imagetoolbar=&quot;false&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>language</strong><br />
Language used by the site, in example: <code>fi, en, de, se</code>.<br />
Example: <code>language=&quot;en&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>robots</strong><br />
How should robots navigate. Valid values are <code>index, noindex, follow, nofollow</code> that can be compined.<br />
Example: <code>robots=&quot;index, follow&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>author</strong><br />
Author name that you wan&#8217;t to show as page&#8217;s author. Usually you, company or the website&#8217;s name.<br />
Example: <code>author=&quot;John Doe&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>useauthor</strong><br />
If selected and filled, <code>&lt;txp:author /&gt;</code> is used for the author-meta, and <code>author</code>-attribute will be overrided, when viewing an induvidual article.<br />
Example: <code>useauthor=&quot;1&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>copyright</strong><br />
Outputs copyright-meta. Used for the content.<br />
Example: <code>copyright=&quot;Copyrihts &amp;copy; 2007 John Doe&quot;</code> Default: <code>&quot;&quot;</code></p>

	<h4>Description related attributes</h4>

	<p><strong>description</strong><br />
A default meta description that will be used in article list context, or if there isn&#8217;t an article description to show and <code>description_replacement</code> is set on.<br />
Example: <code>description=&quot;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce at dui eget est congue aliquet. Quisque sed nunc&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>description_from</strong><br />
Which field is used for the automatic meta description. The attribute takes comma seperated list of fields. The first field in the list that isn&#8217;t empty is used as the meta description. Available values: <code>body</code>, <code>excerpt</code> or <code>custom field&#39;s name</code>. If the attribute is empty, then automatic description isn&#8217;t used.<br />
Example: <code>description_from=&quot;body,excerpt,metadescription&quot;</code>  Default: <code>&quot;body,excerpt&quot;</code></p>

	<p><strong>words</strong><br />
Limits the amount of words that are shown in the automatic meta description.<br />
Example: <code>words=&quot;15&quot;</code> Default: <code>&quot;25&quot;</code></p>

	<p><strong>maxchars</strong><br />
The maximum number of characters in the generated automatic meta description.<br />
Example: <code>maxchars=&quot;170&quot;</code> Default: <code>&quot;250&quot;</code></p>

	<p><strong>description_trail</strong><br />
Ending trail used in the end of the automatic metadescription. Trail is only shown if the description is longer than the limit set by <code>maxchars</code> and <code>words</code>.<br />
Example: <code>description_trail=&quot;&quot;</code> Default:  <code>&quot;&amp;hellip;&quot;</code></p>

	<p><strong>description_replacement</strong><br />
If set on (<code>1</code>) and there isn&#8217;t automatic description available, use <code>description</code> attribute instead. By default this feature is not used.<br />
Example: <code>description_replacement=&quot;1&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>escape</strong><br />
If set to <code>1</code>, will escape raw Textile from description. Default is unset, and the feature is not used. Usually this feature isn&#8217;t required, but it might be good if you have description in a custom field and you are using Textile there. Textile in custom fields isn&#8217;t by default genenrated by Textpattern.<br />
Example: <code>escape=&quot;1&quot;</code> Default: <code>&quot;&quot;</code></p>

	<h4>Keyword related attributes</h4>

	<p><strong>keywords</strong><br />
Default keywords that will be used as keyword meta in article list context, or if there isn&#8217;t any keywords defined for article and <code>keywords_replacement</code> attribute is set on.<br />
Example: <code>keywords=&quot;life, Doe, cat, dog&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>keywords_from</strong><br />
Which field is used for the keyword meta. The attribute takes comma seperated list of fields. The first field in the list that isn&#8217;t empty is used as the keywords. Available values, any article field: <code>keywords</code>, <code>body</code>, <code>excerpt</code> or <code>custom field&#39;s name</code>. If empty, the feature isn&#8217;t used.<br />
Example: <code>keywords_from=&quot;keywords,excerpt&quot;</code>  Default: <code>&quot;keywords&quot;</code></p>

	<p><strong>keywords_replacement</strong><br />
If there isn&#8217;t keywords available for an article, use default defined in <code>keywords</code> attribute instead.<br />
Example: <code>keywords_replacement=&quot;1&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>keywords_limit</strong><br />
Limits the words used in the keywords. Takes even number.<br />
Example: <code>keywords_limit=&quot;5&quot;</code> Default: <code>&quot;25&quot;</code></p>

	<h4>Redirect related attributes</h4>

	<p><strong>messy_to_clean_redirect</strong><br />
Use messy to clean redirect. Redirects messy requrests to clean urls. Use this only if you use clean urls. With messy urls this only causes eternal loop.<br />
Example: <code>messy_to_clean_redirect=&quot;1&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>redirect_code</strong><br />
The code of redirection, value should be <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">three numeric stannard status code protocol.</a><br />
Example: <code>redirect_code=&quot;302&quot;</code> Default: <code>&quot;301&quot;</code></p>

	<h4>Rel link related attributes</h4>

	<p><strong>relnext</strong><br />
Use rel link to point next page&#8217;s location to the browser. <code>relnext</code> attribute&#8217;s value is used as <code>&lt;link rel=&quot;next&quot; /&gt;</code> tag&#8217;s <code>title</code>. Ideal values are <code>Next</code>, <code>Go to next</code> and so on. The attribute, <code>relnext</code>, adds a next rel link meta that points to the next section page or article by posting date. If attribute is used (filled) then used, if unset (empty) then not.<br />
Example: <code>relnext=&quot;Next&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>relprev</strong><br />
Use rel link to point previous page&#8217;s location to the browser. <code>relprev</code> attribute&#8217;s value is used as <code>&lt;link rel=&quot;prev&quot; /&gt;</code> tag&#8217;s <code>title</code>. Ideal values are <code>Previous</code>, <code>Go to prev</code> and so on. The attribute, <code>relprev</code>, adds a next rel link meta that points to the previous section page or article by posting date. If attribute is used (filled) then used, if unset (empty) then not.<br />
Example: <code>relprev=&quot;Previous&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>prev_url</strong><br />
Manually defines relative prev url. Value should be a <span class="caps">URL</span> address. The <span class="caps">URL</span> is only used if automatic <span class="caps">URL</span> isn&#8217;t found.<br />
Example: <code>prev_url=&quot;http://www.example.com/path/to/id&quot;</code> Default: <code>&quot;&quot;</code></p>

	<p><strong>next_url</strong><br />
Manually defines relative next url. Value should be a <span class="caps">URL</span> address. The <span class="caps">URL</span> is only used if automatic <span class="caps">URL</span> isn&#8217;t found.<br />
Example: <code>prev_url=&quot;http://www.example.com/path/to/id&quot;</code> Default: <code>&quot;&quot;</code></p>

	<h3 id="example">Examples</h3>

	<p><strong>#1: Basic usage</strong></p>

<pre><code>&lt;txp:rah_metas keywords=&quot;dog, cat, house&quot; description=&quot;Lorem lipsum&quot; maxchars=&quot;170&quot; words=&quot;15&quot; /&gt;
</code></pre>

	<p><strong>#2: Using content preferring.</strong> First look at the custom field, then main (excerpt, body) fields.</p>

<pre><code>&lt;txp:rah_metas description_from=&quot;MyCustomFieldName&quot; prefercontent=&quot;1&quot; /&gt;
</code></pre>

	<p><strong>#3: Use rah_metas tag inside <a href="http://textpattern.net/wiki/index.php?title=article_custom">article_custom</a> block</strong></p>

	<p>If rah_metas is placed directly inside article_custom (or article) tag, it can be used to pull the meta data from specific article.</p>

<pre><code>&lt;txp:article_custom id=&quot;5&quot;&gt;
	&lt;txp:rah_metas /&gt;
&lt;/txp:article_custom&gt;
</code></pre>

	<p>In the code above, we took the meta data from the article where the ID is 5.</p>

	<h3 id="changelog">Changelog</h3>

	<p><strong>Version 1.3</strong></p>

	<ul>
		<li>Now <code>description_from</code> and <code>keywords_from</code> take comma seperated list of fields. The first field in the list that isn&#8217;t empty is used as keywords or description.</li>
		<li>Removed attribute <code>prefercontent</code>. Using the attribute will throw notice in testing or debugging mode.</li>
	</ul>

	<p><strong>Version 1.2</strong></p>

	<ul>
		<li>Now the <code>&lt;txp:rah_metas/&gt;</code> tag can be also used <em>directly inside</em> <code>&lt;txp:article_custom/&gt;</code> and <code>&lt;txp:article/&gt;</code> blocks. That means that the tag now works in article lists. You just have to point it to the article. See example number 3.</li>
		<li>Now <em>any</em> article field can be used in <code>description_from</code> and <code>keywords_from</code> attributes. Even title, authorid, override_form or status.</li>
		<li>Now dublicate keyword &#8220;uniqueing&#8221; is done with <code>array_unique()</code>.</li>
		<li>Fixed keywords code escaping.</li>
	</ul>

	<p><strong>Version 1.1</strong></p>

	<ul>
		<li>Added: attribute <code>keywords_limit</code>.</li>
		<li>Added: removes doublicated words from keywords.</li>
		<li>Added: list view&#8217;s description is effected by word and character limits.</li>
		<li>Fixed double <code>&quot;=&quot;</code> define bug.</li>
		<li>Now <code>escape</code> attribute effects also body and expert, not only custom fields.</li>
		<li>Now keywords are escaped, striped for tags and parsed.</li>
		<li>Counts white space into chars.</li>
		<li>Removed imagetoolbar attribute validation.</li>
	</ul>

	<p><strong>Version 1.0.5</strong></p>

	<ul>
		<li>Added attribute:  <code>escape</code>.</li>
		<li>Rebuild description&#8217;s word and chars counting: now always counts correctly: doesn&#8217;t ever cut words.</li>
		<li>Optimized parsing and speed: plugin is around 20% faster than before.</li>
		<li>Removes <code>&amp;#8230;</code> from end of the description if trails are used and description is cut from context and shortened.</li>
	</ul>

	<p><strong>Version 1.0.4</strong></p>

	<ul>
		<li>Added attribute:  <code>relnext</code>.</li>
		<li>Added attribute: <code>relprev</code>.</li>
		<li>Minified amount of used globals by one.</li>
	</ul>

	<p><strong>Version 1.0.3</strong></p>

	<ul>
		<li>Fixed last words truncate bug.</li>
	</ul>

	<p><strong>Version 1.0.2</strong></p>

	<ul>
		<li>Fixed some typos in documention.</li>
		<li>Now <code>prefercontent</code> also works with custom_fields.</li>
	</ul>

	<p><strong>Version 1.0.1</strong></p>

	<ul>
		<li>Debugged version 1.0: status now stable.</li>
		<li>Fixed a bug: now whitespace is stripped from beginning and end of the description content.</li>
	</ul>

	<p><strong>Version 1.0</strong></p>

	<ul>
		<li>Improved documentation.</li>
		<li>Little speed improvement.</li>
		<li>Removed <code>charset</code>-attribute, it ain&#8217;t needed as Textpattern sends charset via headers &#8211; and it must not differ.</li>
		<li>Merged <code>customfieldexcerpt</code>-attribute with <code>description_from</code>.</li>
		<li>Included redirecting functions that prevent double content when using clean urls.</li>
		<li>Validates <code>imagetoolbar</code>-attribute to false or true.</li>
		<li>Added attribute: <code>description_replacement</code>.</li>
		<li>Added attribute: <code>keywords_replacement</code>.</li>
		<li>Added attribute: <code>description_from</code></li>
		<li>Added attribute: <code>messy_to_clean_redirect</code>.</li>
		<li>Added attribute: <code>redirect_code</code>.</li>
		<li>Added attribute: <code>description_trail</code>.</li>
		<li>Added invalid charasters removing for custom fields.</li>
		<li>Removed Textile removing from body and excerpt, that was meant to remove Textile + <span class="caps">XHTML</span> bugs caused by user&#8217;s invalid article code, and used instead body_html, and just stripped <span class="caps">HTML</span>: it&#8217;s faster.</li>
		<li>Some users wanted to be able input invalid characters to description: now it is possible, if you turn Textile off: why should we validate meta description, if article&#8217;s body itself is invalid, because writer doesn&#8217;t use valid <span class="caps">HTML</span> special characters.</li>
	</ul>

	<p><strong>Version minor 0.9.2</strong></p>

	<ul>
		<li>One bug fix, created by little one chars typo in the code.</li>
	</ul>

	<p><strong>Version minor 0.9.1</strong></p>

	<ul>
		<li>Removed a debugging error, caused by undefined variable if there were no description.</li>
	</ul>

	<p><strong>Version 0.9</strong></p>

	<ul>
		<li>Added attribute: <code>copyright</code>.</li>
		<li>Added attribute: <code>useauthor</code>.</li>
		<li>Added attribute: <code>customfieldkeywords</code>.</li>
		<li>Added attribute: <code>customfieldexcerpt</code>.</li>
	</ul>

	<p><strong>Version 0.8</strong></p>

	<ul>
		<li>Added Textile remover: removes Textile completely from description</li>
		<li>Cleaned up the code</li>
	</ul>

	<p><strong>Version 0.7</strong></p>

	<ul>
		<li>Fixed bug that appears if single article has no body or excerpt. Only shown in debugging.</li>
	</ul>

	<p><strong>Version 0.6</strong></p>

	<ul>
		<li>Fixed a code-removing bug</li>
		<li>Now removes all code from automatic metadescription</li>
	</ul>

	<p><strong>Version 0.5</strong></p>

	<ul>
		<li>Finished bug-testing</li>
	</ul>

	<p><strong>Version 0.4</strong></p>

	<ul>
		<li>Add missing variable</li>
	</ul>

	<p><strong>Version 0.3</strong></p>

	<ul>
		<li>Compined two seperated functions</li>
		<li>Improved the code by fixing globals</li>
	</ul>

	<p><strong>Version 0.2</strong></p>

	<ul>
		<li>Replaced automatic-medescription&#8217;s ending points <code>&amp;#8230;</code> with <code>&amp;hellip;</code></li>
		<li>Added new attribute: <code>imagetoolbar</code></li>
	</ul>

	<p><strong>Version 0.1</strong></p>

	<ul>
		<li>First release</li>
	</ul>

	<h3 id="known-issues">Known issues</h3>

	<p>Redirects might not always work on old fast-cgi (requires clarifation), but on other systems fine.</p>

	<h3 id="thanks-to">Thanks to</h3>

	<ul>
		<li>All folks that thanked me by making this plugin available.</li>
		<li>rolograaf and pat64 for great ideas of keywords.</li>
		<li>fuls, strawberryfusion, jim_01 and ian_ep for reporting me some bugs.</li>
		<li>maniqui for the ideas.</li>
		<li>And all the other great Textpatternists.</li>
	</ul>