[wp-trac] Re: [WordPress Trac] #2499: Rework Link Categories

WordPress Trac wp-trac at lists.automattic.com
Sun Apr 23 17:27:23 GMT 2006


#2499: Rework Link Categories
----------------------------+-----------------------------------------------
       Id:  2499            |      Status:  new                     
Component:  Administration  |    Modified:  Sun Apr 23 17:27:22 2006
 Severity:  normal          |   Milestone:  2.1                     
 Priority:  low             |     Version:  2.0.1                   
    Owner:  ryan            |    Reporter:  ryan                    
----------------------------+-----------------------------------------------
Comment (by karmadude):

 I like the link categories being there, but it would be more powerful if
 it were a tree structure like the post categories. And then if a link
 category tree can be associated with a post category or categories, that
 would be perfect. The reason I am seeking this feature, is because on my
 blog (http://www.counterjumper.com), I have context sensitive links, and I
 want the links to change according to the category of post one is viewing.

 I kind of achive this with the current version of wordpress, but it would
 be more powerful and easier to implement, if wordress supported a category
 tree for links, and then having the ability to associate that with a post
 category. I also feel we should not get rid of the link categories, it is
 important to keep it seperate.

 Here is the get_linkobjectsin method I have added to links.php to get
 links from multiple link categories.


 {{{
 function get_linkobjectsin($category = "-1", $orderby = 'name', $limit =
 -1) {
     global $wpdb;

     $sql = "SELECT * FROM $wpdb->links WHERE link_visible = 'Y'";
     if ($category != -1) {
         $sql .= " AND link_category IN ($category) ";
     }
     if ($orderby == '')
         $orderby = 'id';
     if (substr($orderby,0,1) == '_') {
         $direction = ' DESC';
         $orderby = substr($orderby,1);
     }
     if (strcasecmp('rand',$orderby) == 0) {
         $orderby = 'rand()';
     } else {
         $orderby = " link_" . $orderby;
     }
     $sql .= ' ORDER BY ' . $orderby;
     $sql .= $direction;
     /* The next 2 lines implement LIMIT TO processing */
     if ($limit != -1)
         $sql .= " LIMIT $limit";

     $results = $wpdb->get_results($sql);
     if ($results) {
         foreach ($results as $result) {
             $result->link_url         = $result->link_url;
             $result->link_name        = $result->link_name;
             $result->link_description = $result->link_description;
             $result->link_notes       = $result->link_notes;
             $newresults[] = $result;
         }
     }
     return $newresults;
 }
 }}}

-- 
Ticket URL: <http://trac.wordpress.org/ticket/2499>
WordPress Trac <http://wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list