$output = str_replace('{link}', cute_get_link($get_news, 'post', 'home'), $output); 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;
}
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
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;
}
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!
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.
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.
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
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.
//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);
}
else {
$output = str_replace('{link}', 'post', $output);
}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.
Return to Additional Downloads
Users browsing this forum: No registered users and 0 guests