Latest_Comments 1.1 for 2.5.x

Download plugins, language packs and stuff.

Postby FI-DD » Fri Jul 18, 2008 9:59 am

If you have {title} in the latest comments template and if there is some code which replaces {title} with the actual link then I have no idea why it's not working for you. Sorry.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby flyboy17 » Fri Jul 18, 2008 3:49 pm

hello, thanks
But it's about the link :) {link} --> $output = str_replace('{link}', cute_get_link($get_news), $output);

In fact i just wan't something like {link=home/post} but doesn't work with the plugin.
flyboy17
 
Posts: 63
Joined: Wed Feb 21, 2007 4:32 pm

Postby FI-DD » Tue Jul 29, 2008 5:29 pm

Change it to this:
Code: Select all
$output = str_replace('{link}', cute_get_link($get_news, 'post', 'home'), $output);


Now you have your home/post.
User avatar
FI-DD
Admin
 
Posts: 2971
Joined: Thu Sep 22, 2005 11:27 am
Location: Germany

Postby Ramon » Sun Aug 09, 2009 7:15 pm

For the MYSQL users there's a much nicer way to get the latest comments.. Just add this function somewhere.

Code: Select all
   function latestcomments($number = 5)
   {
      
      global $sql;
         
      $query = $sql->select(array(
             'table'   => 'comments',
             'orderby' => array('date', 'DESC'),
             'limit'   => array(0, $number)
             ));
      
      $output = '
            <h1>Latest '.$number.' comments</h1>
               <ul>'.PHP_EOL;
      
      foreach($query as $row)
      {
         
         $get_news = reset($sql->select(array('table' => 'news', 'where' => array("id = ".$row['post_id']))));
         
         
         echo '<pre>
               userdata
               
               '.PHP_EOL;
         print_r($row);
         echo '</pre>'.PHP_EOL;
         
         echo '<pre>
               postdata
               
               '.PHP_EOL;
         print_r($get_news);
         echo '</pre>
            <hr />'.PHP_EOL;

         
      }
      
      $output .= '
            </ul>'.PHP_EOL;
      
      return $output;
   
   }


Then call it like "echo latestcomments();" if you don't supply a number the default would be 5. If you want the 20 latest comments just use "echo latestcomments(20);"..

This function will only print out the data, so you can shape it yourself :)

---

You can shape it to whatever you want it. This is how I used it -> http://fminside.net/ (The "LAATSTE 5 SITE REACTIES") part ;)
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

Postby PepeT » Mon Aug 24, 2009 10:58 am

Sorry. Could you Ramon be more specific? I mean where exactly I should put this function and so...

thank you very much.


Ramon wrote:For the MYSQL users there's a much nicer way to get the latest comments.. Just add this function somewhere.

Code: Select all
   function latestcomments($number = 5)
   {
      
      global $sql;
         
      $query = $sql->select(array(
             'table'   => 'comments',
             'orderby' => array('date', 'DESC'),
             'limit'   => array(0, $number)
             ));
      
      $output = '
            <h1>Latest '.$number.' comments</h1>
               <ul>'.PHP_EOL;
      
      foreach($query as $row)
      {
         
         $get_news = reset($sql->select(array('table' => 'news', 'where' => array("id = ".$row['post_id']))));
         
         
         echo '<pre>
               userdata
               
               '.PHP_EOL;
         print_r($row);
         echo '</pre>'.PHP_EOL;
         
         echo '<pre>
               postdata
               
               '.PHP_EOL;
         print_r($get_news);
         echo '</pre>
            <hr />'.PHP_EOL;

         
      }
      
      $output .= '
            </ul>'.PHP_EOL;
      
      return $output;
   
   }


Then call it like "echo latestcomments();" if you don't supply a number the default would be 5. If you want the 20 latest comments just use "echo latestcomments(20);"..

This function will only print out the data, so you can shape it yourself :)

---

You can shape it to whatever you want it. This is how I used it -> http://fminside.net/ (The "LAATSTE 5 SITE REACTIES") part ;)
PepeT
 
Posts: 115
Joined: Fri Nov 11, 2005 11:26 am
Location: Finland

Postby alex » Wed Aug 26, 2009 7:00 pm

I think you should put the function in plugins/etc.php file
alex
 
Posts: 24
Joined: Thu Aug 21, 2008 5:05 pm

Postby Ramon » Mon Sep 07, 2009 6:39 pm

If you don't know where to put it you'd best stick with the other way :P

This is what I finally came up with..

Code: Select all
   function stripurl($input)
   {
      
      $search = array('-1.html', '-2.html', '-3.html', '-4.html', '-5.html', '-6.html', '.html', '-');
      $replace = array('', '', '', '', '', '', '', ' ');
      
      $output = str_replace($search, $replace, $input);
      
      return $output;
      
   }
   
   function latestcomments($number = 5)
   {
      
      global $sql, $ipbwi;
      
      if(is_numeric($number) && !empty($number))
      {
         
         $query = $sql->select(array(
                'table'   => 'comments',
                'orderby' => array('date', 'DESC'),
                'limit'   => array(0, $number)
                ));
         
         $output = '
               <h1>Laatste '.$number.' site reacties</h1>
                  <ul>'.PHP_EOL;
         
         foreach($query as $row)
         {
            
            $get_news = reset($sql->select(array('table' => 'news', 'where' => array("id = ".$row['post_id']))));
         
            include '*/member_information_adv.php';
               
            $output .= '
               <li class="comment">
                  <h4>Door <a href="http://fminside.net/forums/index.php?showuser='.$comment_member['id'].'">'.utf8_decode($comment_member['members_display_name']).'</a> in <b><a href="'.cute_get_link($get_news).'#'.$row['id'].'">'.stripslashes(run_filters('news-entry-content', $get_news['title'])).'</a></b><span class="date">'.date('d-m-Y H:i', $row['date']).'</span></h4>
                  <p>'.stripslashes(run_filters('news-entry-content', $row['comment'])).'</p>
               </li>'.PHP_EOL;
         }
         
         $output .= '
               </ul>'.PHP_EOL;
            
      }
      else
      {
      
         $output = '<div class="error">Vul een geldig - numeriek - aantal in.</div>'.PHP_EOL;
      
      }
      
      return $output;
   
   }


The "include '*/member_information_adv.php';" has nothing to do with cnr. It's just something takes makes me able to combine my forums with my cnr installation :)
Image
Ramon
 
Posts: 599
Joined: Wed Oct 12, 2005 8:51 pm
Location: Hoogeveen, NL

Postby typeman » Sat Jan 23, 2010 12:15 am

I was wondering if the plug-in could be set up to have it so that the comments are linked to exactly where the comment was posted.

At the moment it links back to my home page, comments could be posted in "reviews.php" or "blogs.php" yet they will still link back to my home page. Is there anyway to fix this problem? :)

Thanks in advance!
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby DarkSlim » Sat Jan 23, 2010 8:28 am

typeman wrote:I was wondering if the plug-in could be set up to have it so that the comments are linked to exactly where the comment was posted.

At the moment it links back to my home page, comments could be posted in "reviews.php" or "blogs.php" yet they will still link back to my home page. Is there anyway to fix this problem? :)

Thanks in advance!


If you open the .php plugin file for it, you will see it says:
Add name tags (<a name={comment-id}> to your comments template so when someone click
a displayed comment they will navigate to the comment on the page.
User avatar
DarkSlim
 
Posts: 296
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby typeman » Sat Jan 23, 2010 8:43 am

DarkSlim wrote:
typeman wrote:I was wondering if the plug-in could be set up to have it so that the comments are linked to exactly where the comment was posted.

At the moment it links back to my home page, comments could be posted in "reviews.php" or "blogs.php" yet they will still link back to my home page. Is there anyway to fix this problem? :)

Thanks in advance!


If you open the .php plugin file for it, you will see it says:
Add name tags (<a name={comment-id}> to your comments template so when someone click
a displayed comment they will navigate to the comment on the page.


Hey,

I saw that and I currently have that set up. The only problem is, if my {link} tag in the .php file is pointing at my home page (taking the web-path i chose in the Cutenews system settings) so having that in would still link to

http://www.mysite.com/index.php?title=TITLE#comment1

when infact I want it to link to the part of the site where the news article is actually posted (e.g. reviews.php or news.php) :)

Hope that's made things a little clearer :)

Thanks for the help anyway :)
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby DarkSlim » Sun Jan 24, 2010 8:21 am

typeman wrote:
DarkSlim wrote:
typeman wrote:I was wondering if the plug-in could be set up to have it so that the comments are linked to exactly where the comment was posted.

At the moment it links back to my home page, comments could be posted in "reviews.php" or "blogs.php" yet they will still link back to my home page. Is there anyway to fix this problem? :)

Thanks in advance!


If you open the .php plugin file for it, you will see it says:
Add name tags (<a name={comment-id}> to your comments template so when someone click
a displayed comment they will navigate to the comment on the page.


Hey,

I saw that and I currently have that set up. The only problem is, if my {link} tag in the .php file is pointing at my home page (taking the web-path i chose in the Cutenews system settings) so having that in would still link to

http://www.mysite.com/index.php?title=TITLE#comment1

when infact I want it to link to the part of the site where the news article is actually posted (e.g. reviews.php or news.php) :)

Hope that's made things a little clearer :)

Thanks for the help anyway :)


Oh yeah, this is infect a problem I encountered, and I just wrote a new code
in the plugin so it will take the categories of each post that the comment is for
and will check the categories for certain categories, which I know I will never
use more than one on an article, and each one refers to a different page to open. :)

I'll share the code when I'll get home. ;)
User avatar
DarkSlim
 
Posts: 296
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby typeman » Tue Jan 26, 2010 10:42 am

DarkSlim wrote:
typeman wrote:
DarkSlim wrote:
typeman wrote:I was wondering if the plug-in could be set up to have it so that the comments are linked to exactly where the comment was posted.

At the moment it links back to my home page, comments could be posted in "reviews.php" or "blogs.php" yet they will still link back to my home page. Is there anyway to fix this problem? :)

Thanks in advance!


If you open the .php plugin file for it, you will see it says:
Add name tags (<a name={comment-id}> to your comments template so when someone click
a displayed comment they will navigate to the comment on the page.


Hey,

I saw that and I currently have that set up. The only problem is, if my {link} tag in the .php file is pointing at my home page (taking the web-path i chose in the Cutenews system settings) so having that in would still link to

http://www.mysite.com/index.php?title=TITLE#comment1

when infact I want it to link to the part of the site where the news article is actually posted (e.g. reviews.php or news.php) :)

Hope that's made things a little clearer :)

Thanks for the help anyway :)


Oh yeah, this is infect a problem I encountered, and I just wrote a new code
in the plugin so it will take the categories of each post that the comment is for
and will check the categories for certain categories, which I know I will never
use more than one on an article, and each one refers to a different page to open. :)

I'll share the code when I'll get home. ;)


Just wondered if you were able to post the code yet :)
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby DarkSlim » Wed Jan 27, 2010 12:41 pm

Okay, here it is, this code will give you the option to
play with the path of the page opening using the tag {link}

Here is an example, if I have catgeroy id 1 is news
category id 2 is reviews
and category id 3 is articles
Code: Select all
//DarkSlim's - choose link page

$result = mysql_query("SELECT * FROM cute_news
WHERE id=$xid");

$row = mysql_fetch_array($result);

$pcats = $row['category'];

if(strstr($pcats, '1') != '0'){
  $output = str_replace('{link}', 'news', $output);
} else if(strstr($pcats, '2') != '0'){
    $output = str_replace('{link}', 'reviews', $output);
} else if(strstr($pcats, '3') != '0'){
    $output = str_replace('{link}', 'articles', $output);
} else {
    $output = str_replace('{link}', 'post', $output);
}


Basically it checks in the catogries field of the post
and searches for a catogey, to open it in the wonted
page, like for news category (id 1) in the news.php
So we are looking to find each category and telling
the {link} tag what to be for the category we find.
This also means, that you'de be better not having
the post in more than one of these categories as it
will just pick the first it finds.

More info
The function: strstr($pcats, '1') looks for the category id number 1
which in our example is 'news', and if it finds it between the categories
of that post it will change the {link} tag to whatever you want, in this
example for just the string 'news', you can change it to whatever you whish.

The last thing:
Code: Select all
else {
    $output = str_replace('{link}', 'post', $output);
}


Means that if he hasn't found any of the categories we had,
if it's even possible, then you decide to which page it will go,
in the example it links to a page called 'post'.

You just need to use the {link} tag in the latest_comments template
as you whish.
User avatar
DarkSlim
 
Posts: 296
Joined: Thu Aug 06, 2009 4:18 pm
Location: IL

Postby typeman » Wed Jan 27, 2010 8:45 pm

DarkSlim wrote:Okay, here it is, this code will give you the option to
play with the path of the page opening using the tag {link}

Here is an example, if I have catgeroy id 1 is news
category id 2 is reviews
and category id 3 is articles
Code: Select all
//DarkSlim's - choose link page

$result = mysql_query("SELECT * FROM cute_news
WHERE id=$xid");

$row = mysql_fetch_array($result);

$pcats = $row['category'];

if(strstr($pcats, '1') != '0'){
  $output = str_replace('{link}', 'news', $output);
} else if(strstr($pcats, '2') != '0'){
    $output = str_replace('{link}', 'reviews', $output);
} else if(strstr($pcats, '3') != '0'){
    $output = str_replace('{link}', 'articles', $output);
} else {
    $output = str_replace('{link}', 'post', $output);
}


Basically it checks in the catogries field of the post
and searches for a catogey, to open it in the wonted
page, like for news category (id 1) in the news.php
So we are looking to find each category and telling
the {link} tag what to be for the category we find.
This also means, that you'de be better not having
the post in more than one of these categories as it
will just pick the first it finds.

More info
The function: strstr($pcats, '1') looks for the category id number 1
which in our example is 'news', and if it finds it between the categories
of that post it will change the {link} tag to whatever you want, in this
example for just the string 'news', you can change it to whatever you whish.

The last thing:
Code: Select all
else {
    $output = str_replace('{link}', 'post', $output);
}


Means that if he hasn't found any of the categories we had,
if it's even possible, then you decide to which page it will go,
in the example it links to a page called 'post'.

You just need to use the {link} tag in the latest_comments template
as you whish.


Hey, thanks :)
Only one thing... where do i post it in latest_comments.php? :)

Edit: For some reason, the problem seems to of fixed itself :S. The comments are synced up with my posts on the main page. :? However, it'd still be great to have this as it'll help with SEO etc XD

Edit 2: Would it be possible to add the commenter's avatar to the thing to be able to be used as a tag also? :D
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

Postby typeman » Wed Feb 10, 2010 11:07 pm

Anyone able to help me intergrate avatars with this? :)
typeman
 
Posts: 102
Joined: Sat Oct 17, 2009 7:38 am

PreviousNext

Return to Additional Downloads



Who is online

Users browsing this forum: No registered users and 0 guests

cron