My first ever plugin for the Textpattern CMS.
A Textpattern CMS article tag that makes the keywords clickable.
If you downloaded Version 0.1, you probably found that it did not work. Use this one.
Download here: daz_clickable_keywords-0.2.txt
The plugin, daz_clickable_keywords, is a drop-in replacement for <txp:keywords /> Place it in an article form and it will display the article’s keywords plus link to a URL with a query using that keyword. Use it to link to other articles with that keyword, or grab the keyword for your own programming.
<txp:daz_clickable_keywords /><txp:daz_clickable_keywords section ="keywords" wraptag="ul" break="li" class="list-inline" breakclass="list-inline-item" keyword="keyword" />To show the articles indicated by the keywords, you’ll need to place a <txp:article> or <txp:article_custom> tag on the ‘section’ page, like so:
<txp:article_custom keywords='<txp:page_url type="keyword" />' /><txp:page_url type=“keyword” /> is a regular Textpattern tag. Make sure that you change ‘keyword’ in that tag to what ever word you use as ‘keyword’ in <txp:daz_clickable_keywords />
The attributes are:
section
The Textpattern section that you want linked in the URL.
Default is ‘keywords’. If you want to use ‘keywords’ as a section, you’ll need to create it as a section first.
wraptag
The HTML tags wrapping the list of keywords:
ul for unordered list, eg <ul></ul>
ol for numbered list, eg <ol></ol>
p for paragraph, eg <p></p>
Default is unset.
break
The HTML tags wrapping each individual keyword
li for list, eg <li></li>
p for paragraph, eg <p></p>
Default is unset.
class
The CSS class for the wraptag
Default is unset.
breakclass
The CSS class for the break tag
Default is unset.
keyword
The identifier in the URL that indicates the linked keyword
Default is keyword.
Assuming your article keywords are: Sammy, Lola, Floyd, Bob, Doug, Edith
<txp:daz_clickable_keywords section = "tags" />Returns: <a href="/tags/?keyword=Sammy">Sammy</a> (etc)
<txp:daz_clickable_keywords keyword = "inventory" />Returns: <a href="/keywords/?inventory=Lola">Lola</a> (etc)
bc. <txp:daz_clickable_keywords wraptag = "ul" break = "li" />Returns: <ul><li><a href="/keywords/?keyword=Bob">Bob</a></li> (etc) <li><a href="/keywords/?keyword=Doug">Doug</a></li></ul>
<txp:daz_clickable_keywords wraptag = "ul" break = "li" class="list-inline" breaktag="list-inline-item" />Returns: <ul class="list-inline"><li class="list-inline-item"><a href="/keywords/?keyword=Edith">Edith</a></li> (etc)</ul>
MIT License
Copyright © 2022 Darren Atwater
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Darren Atwater
Website: ReverendMoonbeam.com
Email: [email protected]