Last active
December 14, 2015 07:29
-
-
Save whaleen/5050745 to your computer and use it in GitHub Desktop.
Display ‘tags’ (Textpattern Article Keywords) from articles by logged user with tru_tags. This is only to show a user a list of the Article Keywords they have used as they are logged in.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
Textpattern Plugins: | |
* cbe_frontauth: http://www.clairebrione.com/?rah_plugin_download=cbe_frontauth | |
* tru_tags: http://www.rainskit.com/reference/537/tru_tags-releases | |
* smd_query: http://stefdawson.com/sw/plugins/smd_query | |
--> | |
<!-- Use cbe_frontauth to make the variable 'logged_user' from logged user's name for use in smd_query later --> | |
<txp:smd_bio_author author='<txp:cbe_frontauth_whois type="name" />'> | |
<txp:variable name="logged_user" value='<txp:cbe_frontauth_whois type="name" />' /> | |
</txp:smd_bio_author> | |
<!-- .tags targeted in CSS and jQuery --> | |
<div class="tags"> | |
<!-- Remove duplicate tags within --> | |
<txp:if_different> | |
<!-- Use smd_query plugin: --> | |
<txp:smd_query query="SELECT id | |
FROM textpattern WHERE authorid = '?logged_user' AND section = 'your_section_name'"> | |
<!-- Display user tags --> | |
<txp:article_custom id="{id}" limit="999"> | |
<txp:tru_tags_from_article break="" linkpath="<txp:site_url />library?tag=" /> | |
</txp:article_custom> | |
</txp:smd_query> | |
</txp:if_different> | |
</div> | |
<!-- CSS--> | |
<style> | |
.tags a { | |
color: #666; | |
background-color: #f2f2f2; | |
border: solid 1px #e6e6e6; | |
border-radius: 3px; | |
padding: 10px; | |
margin-right: 5px; | |
line-height: 45px; | |
} | |
.tags a:last {margin-right: 0;} | |
</style> | |
<!-- jQuery: Hide duplicate links in tags list generated from tru_tags using smd_query --> | |
<script> | |
var seen = {}; | |
$('.tags a').each(function() { | |
var txt = $(this).text(); | |
if (seen[txt]) | |
$(this).remove(); | |
else | |
seen[txt] = true; | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment