We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Simple Tags 1.6 - weblog entry tagging

Development and Programming

silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz

Somehow I seem to be unable to find the original release thread, so I’ll start a new one here.

A new version of the Simple Tags Extension/Module has been released.

Changes since last release: • parameter added to the tagcloud-tag to order by popularity • added AJAX auto-suggest/-complete for tagfields, can be (de)activated in the extension settings • added the facility to pass muliple tags to the taglist-tag; tags can be separated by (or) to retrieve entries tagged with any or (and) to retrieve entries tagged with all of the supplied tags
• extended the tagheader-tag to accept multiple tags as well • new tag: exp:simpletag:related_tags; displays tags related to the one(s) currently viewed • new tag: exp:simpletag:related_tags_cloud; same as above but in a cloud view • new tag: exp:simpletag:related_entries, list related entries based on tags in common • new tag: exp:simpletag:recent_tags; list recently used tags • new tag: exp:simpletag:tagloop; returns all tags and their url_titles • general overhaul of the module code • improved ordering of the tagcloud • fixed a bug that could affect batch-retagging • removed a typo in the extension

Details about the new functions can be found in the Docs.

       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz

Thanks to docflo a bug has been ironed out and the AJAX autosuggest feature now also works in Stand-alone entry forms. Current version is now 1.6.2

       
tehlupin's avatar
tehlupin
12 posts
16 years ago
tehlupin's avatar tehlupin

Installed it today and it works great.

Just one thing - is it possible to display the custom fields of related entries?

       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz
Just one thing - is it possible to display the custom fields of related entries?

Do you mean “Related entries” generated by {exp:simpletag:related_entries}-tag?

Not directly but since you have the entry_id available you could use an {exp:weblog:entries}-tag in an embedded template to display whatever you want from the related entries. Like:

{exp:weblog:entries}    
  {exp:simpletag:related_entries entry_id="{entry_id}" threshold="2" orderby="weight"}

    {embed='whatever/entrydata' entryid='{rel_entry_id}'}

  {/exp:simpletag:related_entries}
{/exp:weblog:entries}

And in whatever/entrydata:

{exp:weblog:entries entry_id="{embed:entryid}" dynamic="off"}    
  {title}

  {custom_field_1}

  {custom_field_2}

{/exp:weblog:entries}
       
tehlupin's avatar
tehlupin
12 posts
16 years ago
tehlupin's avatar tehlupin

Thanks, that did the trick.

       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz

You’re welcome.

       
Matt Weinberg's avatar
Matt Weinberg
489 posts
16 years ago
Matt Weinberg's avatar Matt Weinberg

Silenz– how does this compare to the solspace tag module?

       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz

I’m afraid I’m the wrong person to ask, as I don’t know much about Solspace’s Tag other than that it exists and is certified. I think Solspace also covers the gallery module which I don’t. Well, and ST is free, although I really appreciate donations.

Perhaps there’s someone around that used both and can give a more detailed comparison.

       
tehlupin's avatar
tehlupin
12 posts
16 years ago
tehlupin's avatar tehlupin

I haven’t used Solspace’s module either, but I’ve been using this extension for the last couple days and I absolutely love it. It’s incredibly simple yet incredibly powerful. I recommend installing it for yourself. 😊

Anyway, the real reason I’m here (heh)–is there a way to append a trailing slash onto the url, just for the sake of consistency?

       
silenz's avatar
silenz
1,648 posts
16 years ago
silenz's avatar silenz
I haven’t used Solspace’s module either, but I’ve been using this extension for the last couple days and I absolutely love it. It’s incredibly simple yet incredibly powerful. I recommend installing it for yourself. 😊

Glad to hear.

Anyway, the real reason I’m here (heh)–is there a way to append a trailing slash onto the url, just for the sake of consistency?

Well, I could add that to the next release.

       
Mark Bowen's avatar
Mark Bowen
12,637 posts
16 years ago
Mark Bowen's avatar Mark Bowen

Fantastic new version this, well done. Absolutely brilliant!

Was just wondering though if anyone knew how you could make something with Ajax so that you could show all the tags using the Tag Cloud and then click on each one to do one of two things :

1 - In SAEF add them to the field you have set up for the tags and automatically place the commas in to the field so that people can add tags to entries.

2 - On a template allow people to build a segment URL of sorts so that they can search multiple criteria at once so let’s say you had :

expressionengine video image audio

as tags that are in the system. These would all show on the page and then you could say click on expressionengine and then image and also click on one of the two separate and or or words and a link would appear somewhere on the page allowing the user to create a url such as :

http://www.example.com/tagged-entries/expressionengine(or)image

Hope some of that made some sense?

Fantastic add-on though.

Best wishes,

Mark

       
Yuri's avatar
Yuri
273 posts
16 years ago
Yuri's avatar Yuri

I’ve made a small addition to Simple Tags module, that allows to output the tag cloud filtered by entry author.

To enable, open mod.simpletag.php find the function tagcloud() and replace its code with following

function tagcloud()
  {
    global $TMPL, $DB;

        $output = "";
        $weblog_sql = "";
        $tags = array();
        

       if ($weblog = $TMPL->fetch_param('weblog'))    {
            $weblog_sql = $this->weblog_sql($weblog);
            if ( $weblog_sql === FALSE ) return;           
        }   
    
    $orderby = ( ! $TMPL->fetch_param('orderby')) ? '' : $TMPL->fetch_param('orderby');
        $limit = ( ! $TMPL->fetch_param('limit')) ? '' : $TMPL->fetch_param('limit')+0;
        $max_size = ( ! $TMPL->fetch_param('font_max')) ? '250' : $TMPL->fetch_param('font_max')+0;
        $min_size = ( ! $TMPL->fetch_param('font_min')) ? '100' : $TMPL->fetch_param('font_min')+0;
        $path = ( ! $TMPL->fetch_param('path')) ? '' : $TMPL->fetch_param('path');
        $username = ( ! $TMPL->fetch_param('username')) ? '' : $TMPL->fetch_param('username');
        $author = ( ! $TMPL->fetch_param('author')) ? '' : $TMPL->fetch_param('author');

    if ($author!='') {
      $sql = "SELECT st.realtag, COUNT(st.entry_id) AS quantity FROM exp_sz_simple_tags AS st, exp_weblog_titles AS t WHERE st.entry_id=t.entry_id AND t.author_id='$author' AND $weblog_sql GROUP BY tag ORDER BY tag ASC;";
      if ( $limit > 0 ) $sql = "SELECT st.realtag, COUNT(st.entry_id) AS quantity FROM exp_sz_simple_tags AS st, exp_weblog_titles AS t WHERE st.entry_id=t.entry_id AND t.author_id='$author' AND $weblog_sql GROUP BY tag ORDER BY quantity DESC LIMIT $limit;";
    } else if ($username!='') {
      $sql = "SELECT st.realtag, COUNT(st.entry_id) AS quantity FROM exp_sz_simple_tags AS st, exp_weblog_titles AS t, exp_members AS m WHERE st.entry_id=t.entry_id AND t.author_id=m.member_id AND m.username='$username' AND $weblog_sql GROUP BY tag ORDER BY tag ASC;";
      if ( $limit > 0 ) $sql = "SELECT st.realtag, COUNT(st.entry_id) AS quantity FROM exp_sz_simple_tags AS st, exp_weblog_titles AS t, exp_members AS m WHERE st.entry_id=t.entry_id AND t.author_id=m.member_id AND m.username='$username' AND $weblog_sql GROUP BY tag ORDER BY quantity DESC LIMIT $limit;";
    } else {
      $weblog_sql = " WHERE ".$weblog_sql;
      $sql = "SELECT realtag, COUNT(entry_id) AS quantity FROM exp_sz_simple_tags st $weblog_sql GROUP BY tag ORDER BY tag ASC;";
    if ( $limit > 0 ) $sql = "SELECT realtag, COUNT(entry_id) AS quantity FROM exp_sz_simple_tags st $weblog_sql GROUP BY tag ORDER BY quantity DESC LIMIT $limit;";
    }
    
    $query = $DB->query($sql);
        foreach ($query->result as $row) {
          $tags[$row['realtag']] = $row['quantity'];
      }
    
    if (count($tags)==0) return; // nothing to output
  
        $output = $this->help_cloud ($tags, $path, $max_size, $min_size, $orderby);
    
    return $output;
    
  }

To use, call {exp:simpletag:tagcloud} with parametres username=”author-username” or author=”author-ID”

(btw, I get error You are not authorized to perform this action when trying to comment corresponding entry on utilitees.silenz.org)

       
Yuri's avatar
Yuri
273 posts
16 years ago
Yuri's avatar Yuri

You may also want to add this kind of support for exp:simpletag:taglist To do this, replace the taglist function code with: <pre><code> function taglist () {

    global $TMPL, $DB, $FNS, $REGX;

    $weblog_sql = "";

    $params = $TMPL->tagparams;

    if ( !isset($params['tagname']) ) 
    {
        return;
    }
    else
    {
         $tagname = $params['tagname'];
    }

        list($look_for,$tags,$tagname) = $this->help_look_for($tagname); 

        $username = ( ! $TMPL->fetch_param('username')) ? '' : $TMPL->fetch_param('username');
      $author = ( ! $TMPL->fetch_param('author')) ? '' : $TMPL->fetch_param('author');


       if ($weblog = $TMPL->fetch_param('weblog'))    
       {
            $weblog_sql = $this->weblog_sql($weblog);

            if ( $weblog_sql === FALSE ) return;                

            $weblog_sql = " AND ".$weblog_sql;
        }             

        if ($author!='') {
    $sql = "SELECT st.entry_id FROM exp_sz_simple_tags AS st, exp_weblog_titles AS t WHERE $look_for AND st.entry_id=t.entry_id AND t.author_id='$author' $weblog_sql;";
  } else if ($username!='') {
    $sql = "SELECT st.entry_id FROM exp_sz_simple_tags AS st, exp_weblog_titles AS t, exp_members AS m WHERE $look_for AND st.entry_id=t.entry_id AND t.author_id=m.member_id AND m.username='$username' $weblog_sql;";
  } else {
    $sql = "SELECT entry_id FROM exp_sz_simple_tags st WHERE $look_for $weblog_sql;";
  }    

    $tagdata = $TMPL->tagdata;
        $entries = array();

    $query = $DB->query($sql);

        if ($query->num_rows > 0) 
        {
            $entries = array();
            foreach ($query->result as $row) {
                $entries[] = $row["entry_id"];         
            }


            // OR = remove duplicates
            if ( strpos($tagname, '(or)') !== FALSE )
        {                
            $entries = array_unique($entries);
        }

        // now for some array magic
        // AND = find multiple values fitting to the number of tags
        if ( strpos($tagname, '(and)') !== FALSE )
        {                
            $entries = array_keys(array_count_values($entries),(count($tags)));
        }

        }

echo “

taglist: “; print_r($entries); if ( count($entries) == 0 ) { $entries = “9999999999”; } elseif ( count($entries) > 1 ) {
$entries = implode(“|”, $entries); } else { $entries = $entries[0]; }

        $tagdata = str_replace("{tagged_entries}", $entries, $tagdata); 


        return $tagdata;



} // end function taglist[/code]
       
ahaywood's avatar
ahaywood
6 posts
16 years ago
ahaywood's avatar ahaywood

I love this add on, however, I’ve run into (hopefully) a (small) problem.

When using the taggify code to display each each entry’s tags, it is outputting the domain name twice in the link. For example, instead of displaying “http://www.amyhaywood.com/index.php?/blog/tags/gtd” it will output “http://www.amyhaywood.com/www.amyhaywood.com/index.php?/blog/tags/gtd”

Here is the code I’m using

TAGGED AS: 
                        {exp:simpletag:taggify path="{path=blog/tags}" delimiter="_-_" weblog="blog"}
                          {blog_tags}
                           {/exp:simpletag:taggify}

Here is the code it’s outputting: <pre><code>TAGGED AS: productivity - gtd - software - apps - mac

                [/code]

This can be found at (in the gray box, at the end of each post: http://www.amyhaywood.com/index.php?/blog/tags/gtd

       
Yuri's avatar
Yuri
273 posts
16 years ago
Yuri's avatar Yuri

ahaywood, seems like you have and error in your site’s settings, paticularly in site URL you have http:/www.amyhaywood.com/ instead of http://www.amyhaywood.com/

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.