| Author |
Message |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Thu Feb 07, 2008 7:36 am |
  |
i want a block to display the latest, say 5 posts in some categories of the NEWS (stories) modules. is it possible? how to do it? |
|
|
   |
 |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Mon Feb 18, 2008 2:16 am |
  |
let me explain the situation again
i have some people like news reporters in my site. say i have 3 of them. they post their reports time to time.
i want a block or something that will display these 3 peoples posts (say the last 10) in the index page. Or let them have one column each, whenever that link is clicked from the index page, it should take to another page where all that persons posts will be available.
what is the best way to do? need ur solution  |
|
|
   |
 |
movieman
Captain


Joined: Feb 29, 2004
Posts: 301
Location: New York
|
Posted:
Mon Feb 18, 2008 12:34 pm |
  |
|
       |
 |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Mon Feb 18, 2008 6:02 pm |
  |
thnx movieman for the reply.
i will check ur site and see if it is what i am looking for. the block i ma looking for is what can display a particular user posts only |
|
|
   |
 |
spottedhog
Captain


Joined: Apr 30, 2004
Posts: 566
|
Posted:
Mon Feb 18, 2008 9:26 pm |
  |
Here is something that may work. Replace "X" with the news reporters "aid".
| Code: |
$result = $db->sql_query("
SELECT sid, title
FROM {$prefix}_stories
WHERE aid=X
ORDER BY sid
DESC LIMIT 5");
while ($row = $db->sql_fetchrow($result))
{
$row['sid']= intval($row['sid']);
$row['title']= check_words(check_html($row['title'], "nohtml"));
$content. ="<strong>·</strong> <a href=\"modules.php?name=News&file=article&sid=$row['sid']\">$row['title']</a><br />";
} |
|
_________________ SMF-Nuke admin
SMF and PHP Nuke integration is ready! Take a look at it by clicking on the link above.
Last edited by spottedhog on Tue Feb 19, 2008 4:58 am; edited 1 time in total |
|
     |
 |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Tue Feb 19, 2008 12:38 am |
  |
thnx spottedhog
i will try it and report back if it works
btw will this code display the category-wise news or reporter-wise news? |
|
|
   |
 |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Tue Feb 19, 2008 4:17 am |
  |
tried with this where "reporter" is the username of the news submitter as u suggested
| Code: |
<?php
#### Generated by Block Creator by Disipal Site (www.disipal.net) ###
if (eregi("block-Block_Creator.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
$content = "$result = $db->sql_query(\" ";
$content .= " SELECT sid, title ";
$content .= " FROM {$prefix}_stories ";
$content .= " WHERE aid=reporter ";
$content .= " ORDER BY sid ";
$content .= " DESC LIMIT 5\"); ";
$content .= " while ($row = $db->sql_fetchrow($result)) ";
$content .= " { ";
$content .= " $row['sid']= intval($row['sid']); ";
$content .= " $row['title']= check_words(check_html($row['title'], \"nohtml\")); ";
$content .= " $content. \"<strong>·</strong> <a href=\\\"modules.php?name=News&file=article&sid=$row['sid']\\\">$row['title']</a><br />\"; ";
$content .= " }";
?> |
it's not working. where do i go wrong? |
|
|
   |
 |
spottedhog
Captain


Joined: Apr 30, 2004
Posts: 566
|
Posted:
Tue Feb 19, 2008 5:06 am |
  |
The query should display the last 5 entries for a specific reporter. If you have 3 reporters, you will need to use the code 3 times but put in a different "aid" for each.
Well.... first of all, do not use a Block Creator. That is the main issue.
Create your own block... and copy the code I have here for the main part.
Also, you have:
aid=reporter
that is not correct... in your nuke_stories database table, look in the "aid" field to find the value you need to put where you have "reporter" now.
You may also want to put the Reporter's name above each query. |
_________________ SMF-Nuke admin
SMF and PHP Nuke integration is ready! Take a look at it by clicking on the link above. |
|
     |
 |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Thu Feb 21, 2008 8:59 am |
  |
tried with this where i replaced the aid with "user name of the newsreporter"
| Code: |
<?php
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
global $prefix, $multilingual, $currentlang, $db;
if ($multilingual == 1) {
$querylang = "WHERE (alanguage='$currentlang' OR alanguage='')";
} else {
$querylang = "";
}
$content = "<table width=\"100%\" border=\"0\">";
$result = $db->sql_query("
SELECT sid, title
FROM {$prefix}_stories
WHERE aid=X
ORDER BY sid
DESC LIMIT 5");
while ($row = $db->sql_fetchrow($result))
{
$row['sid']= intval($row['sid']);
$row['title']= check_words(check_html($row['title'], "nohtml"));
$content. ="<strong>·</strong> <a href=\"modules.php?name=News&file=article&sid=$row['sid']\">$row['title']</a><br />";
}
$content .= "</table>";
$content .= "<br><center>[ <a href=\"modules.php?name=News\">"._MORENEWS."</a> ]</center>";
?> |
still not working. actually i have never created a block. please check the code again for me |
|
|
   |
 |
spottedhog
Captain


Joined: Apr 30, 2004
Posts: 566
|
Posted:
Thu Feb 21, 2008 10:32 am |
  |
2 things.....
firstly, if you are going to use a table, you need to put in the proper html tags to create a table.
for example:
<table><tr><td>
//query content here
</td></tr></table>
^^^please know this is not the exact way to code the block...just showing you the proper way to use html code to create a table.
secondly, you need to put in the author ID where you have the "X"
find: WHERE aid=X
replace "X" with the aid of your reporter. You may need to look in your nuke_stories table to see what the value of "aid" is for each reporter. |
_________________ SMF-Nuke admin
SMF and PHP Nuke integration is ready! Take a look at it by clicking on the link above. |
|
     |
 |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Sun Feb 24, 2008 1:55 am |
  |
i tried WHERE aid=user id of the reporter (replacing the X with the username of the reporter) with and without the table but is not working.
don't know where it i went wrong |
|
|
   |
 |
spottedhog
Captain


Joined: Apr 30, 2004
Posts: 566
|
Posted:
Sun Feb 24, 2008 6:05 am |
  |
Try this....
| Code: |
<?php
if ( !defined('BLOCK_FILE') ) {
Header("Location: ../index.php");
die();
}
global $prefix, $multilingual, $currentlang, $db;
if ($multilingual == 1) {
$querylang = "WHERE (alanguage='$currentlang' OR alanguage='')";
} else {
$querylang = "";
}
$content = "<table width=\"100%\" border=\"0\"><tr><td>";
$result = $db->sql_query("
SELECT sid, title
FROM {$prefix}_stories
WHERE aid='X'
ORDER BY sid
DESC LIMIT 5");
while ($row = $db->sql_fetchrow($result))
{
$row['sid']= intval($row['sid']);
$row['title']= check_words(check_html($row['title'], "nohtml"));
$content. ="<strong>·</strong> <a href=\"modules.php?name=News&file=article&sid=$row['sid']\">$row['title']</a><br />";
}
$content .= "</td></tr></table>";
$content .= "<br /><center>[ <a href=\"modules.php?name=News\">"._MORENEWS."</a> ]</center>";
?> |
There is a small difference with this code. Please notice the X is inside quotes like this: 'X'
That may be the issue... |
_________________ SMF-Nuke admin
SMF and PHP Nuke integration is ready! Take a look at it by clicking on the link above. |
|
     |
 |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Mon Feb 25, 2008 6:08 am |
  |
still it's not working
whenever i upload the block and activate it, only the right blocks in my site is displayed when index page is opened. i made the code with notepad and saved as block-Filename.php. can it be because of using NOTEPAD? |
|
|
   |
 |
spottedhog
Captain


Joined: Apr 30, 2004
Posts: 566
|
Posted:
Mon Feb 25, 2008 8:43 am |
  |
http://www.crimsoneditor.com is a good PHP/HTML editor for Windoz |
_________________ SMF-Nuke admin
SMF and PHP Nuke integration is ready! Take a look at it by clicking on the link above. |
|
     |
 |
moods
Corporal


Joined: Dec 13, 2005
Posts: 72
|
Posted:
Tue Feb 26, 2008 5:37 am |
  |
tried with the text editor. it still didn't work. it has something to do with the script or wat?
i am using phpnuke 8 |
|
|
   |
 |
|
|