From bdd90a680d1d39ccd92ed3c7cca2ad27bd850410 Mon Sep 17 00:00:00 2001 From: krasi georgiev Date: Sun, 30 Oct 2016 13:30:32 +0000 Subject: [PATCH] custom url with tokens for the tags plugin --- .gitignore | 5 ----- bl-plugins/tags/plugin.php | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 33 insertions(+), 9 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 6ac90aee..00000000 --- a/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.DS_Store -bl-content/databases -bl-content/pages -bl-content/posts -bl-content/uploads diff --git a/bl-plugins/tags/plugin.php b/bl-plugins/tags/plugin.php index 978fbd64..8fe85d87 100644 --- a/bl-plugins/tags/plugin.php +++ b/bl-plugins/tags/plugin.php @@ -6,8 +6,15 @@ class pluginTags extends Plugin { { $this->dbFields = array( 'label'=>'Tags', - 'sort'=>'date' + 'sort'=>'date', + 'link'=>'' ); + $this->dbTokens = array( + "[postUrl]", + "[tagName]", + "[tagCount]" + ); + } public function form() @@ -31,7 +38,14 @@ class pluginTags extends Plugin { $html .= ''; } } - $html .= ''; + $html .= ''; + $html .= ''; + + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= '
available tokens '.  implode(', ', $this->dbTokens).' 
'. + htmlspecialchars('[token2] [token3]').'
'; $html .= '
'; return $html; @@ -71,11 +85,26 @@ class pluginTags extends Plugin { return strcmp($a['tagKey'], $b['tagKey']); }); } + + + foreach($tagArray as $tagKey=>$fields) { - // Print the parent - $html .= '
  • '.$fields['name'].' ('.$fields['count'].')
  • '; + // Print the parent + $link=''.$fields['name'].' ('.$fields['count'].')'; + if(!empty($this->getDbField('link'))){ + $replacments=array( + "[postUrl]"=>HTML_PATH_ROOT.$filter.'/'.$fields['tagKey'], html_entity_decode($this->getDbField('link')), + "[tagName]"=>$fields['name'], + "[tagCount]"=>$fields['count'] + ); + $link= html_entity_decode($this->getDbField('link')); + foreach($this->dbTokens as $token){ + $link= str_replace($token,$replacments[$token],$link); + } + } + $html .= "
  • $link
  • "; } $html .= ''; $html .= '';