Home N-13 News Forums Help Search
RegisterForgot password?
How to add image to post necklacesdiscou
Known bugs - 4.0.3 necklacesdiscou

Latest N-13 News 4.0.3

What is N-13 News?
Where can I get help?
Known bugs

Forums Help & Support latest comments list
Ianfellows
Posted on 17 Aug 2010, 10:14:28

Access: Member
Total Posts: 4
Joined: 2010-08-17

if you have many articles, how is a new post seen or flagged up to site users ?
how do users know there is a new comment on one of the news articles ?

is it possible to add a code to get the latest comments into a time ordered list with newest at top that can then be called in php include ?
#2783
Last edited by Ianfellows at 2010-08-17 14:37:56 Reason:
Chris
Posted on 18 Aug 2010, 13:45:43

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

Quote:
if you have many articles, how is a new post seen or flagged up to site users ?
how do users know there is a new comment on one of the news articles ?

is it possible to add a code to get the latest comments into a time ordered list with newest at top that can then be called in php include ?


When you add a new article it automatically gets shown on the news page, by default it gets shown at the top.

To show the 10 latest comments in the order they were posted use this code.

Code:
<?php
require_once('news/db.php');
require_once(
'news/config.php');

$commentstoshow = 10;

$allcomments = DataAccess::fetch(sprintf("SELECT user, email, message, id FROM %s ORDER BY timestamp LIMIT 0 , %s", NEWS_COMMENTS, $commentstoshow));


foreach(
$allcomments AS $comment){
    echo 
$comment['message'] . " - " . $comment['user'] . " - " . $comment['email'] .  "<br />";
}
?>


This will display each comment in a list along with the name of whoever submitted it and the email address they used.
#2784
Ianfellows
Posted on 19 Aug 2010, 21:38:48

Access: Member
Total Posts: 4
Joined: 2010-08-17

the problem is that you never know when an article in the database has a new comment posting. I was therefore hoping to create the list of latest ten articles with new comments, newest at top c/w time of comment posting. Can the code be changed to do that ?
#2786
Last edited by Ianfellows at 2010-08-19 21:48:27 Reason:
Ianfellows
Posted on 22 Aug 2010, 09:43:13

Access: Member
Total Posts: 4
Joined: 2010-08-17

also been trying add a hyperlink in your code, to link to the article / comment.
Can anyone help ?
#2789
Chris
Posted on 22 Aug 2010, 16:41:31

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

This code will show the latest 10 comments along with the news article they've been posted to formatted like so

Quote:
Article title here
* comment message here

Article title asdas
* comment asdasdasdsada

Code:
<?php
require_once('news/db.php');
require_once(
'news/config.php');

$commentstoshow = 10;

$allcomments = DataAccess::fetch(
    
sprintf(
        
"SELECT %s.title AS articletitle, %s.id AS articleid, user, email, message, %s.id AS commentid FROM %s LEFT JOIN %s ON %s.pid = %s.id ORDER BY %s.timestamp LIMIT 0 , %s",
        
NEWS_ARTICLES, NEWS_ARTICLES, NEWS_COMMENTS, NEWS_COMMENTS, NEWS_ARTICLES, NEWS_COMMENTS, NEWS_ARTICLES, NEWS_COMMENTS, $commentstoshow
    
)
);

foreach(
$allcomments AS $comment){
    echo 
'<a href="?id=' . $comment['articleid'] . '#' . $comment['commentid'] . '">' . $comment['articletitle'] . '</a>';
    echo 
'<ul><li>' . $comment['message'] . '</li></ul>';
    
}
?> 
#2790
Knet24
Posted on 23 Aug 2010, 20:18:36

Access: Member
Total Posts: 2
Joined: 2010-08-23

Good evening. Is it possible to display the last ten comments made by the latter on top of the list? The test did show ten schools, but not the latter.
#2793
Knet24
Posted on 25 Aug 2010, 16:37:29

Access: Member
Total Posts: 2
Joined: 2010-08-23

To display the last ten comments

Code:
<?php
require_once('news/db.php');
require_once(
'news/config.php');

$commentstoshow = 10;

$allcomments = DataAccess::fetch(
    
sprintf(
        
"SELECT %s.title AS articletitle, %s.id AS articleid, user, email, message, %s.id AS commentid FROM %s LEFT JOIN %s ON %s.pid = %s.id ORDER BY %

s.timestamp DESC LIMIT 0 , %s"
,
NEWS_ARTICLES, NEWS_ARTICLES, NEWS_COMMENTS, NEWS_COMMENTS, NEWS_ARTICLES, NEWS_COMMENTS, NEWS_ARTICLES, NEWS_COMMENTS, $commentstoshow
)
);

foreach(
$allcomments AS $comment){
    echo 
'<a href="?id=' . $comment['articleid'] . '#' . $comment['commentid'] . '">' . $comment['articletitle'] . '</a>';
    echo 
'<ul><li>' . $comment['message'] . '</li></ul>';
    
}
?> 



#2797
Last edited by Knet24 at 2010-08-25 16:42:11 Reason:
Ianfellows
Posted on 03 Sep 2010, 15:26:17

Access: Member
Total Posts: 4
Joined: 2010-08-17




Chris

Strange bug with your code. If you put the code on same page as the article with comments and security key enabled

then the security key wont work. - 'invalid security key'
posting will work though if security key is turned off
#2831
Chris
Posted on 03 Sep 2010, 19:20:09

Access: Admin
Total Posts: 1395
Joined: 2006-05-19

Ah yes, I should have used another variable other than $allcomments as this is already used within the script, if you change all isntances of the $allcomments variable above to something else, for example $latestcommentsm, it should work fine.
#2832
Network-13.com © 2013