Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Show news from one category in separate page with description and pic

hello, i have this little problem... i want this code to show news text (not- extended, just like normal news) and picture if i have added it from that place where you can edit news. (that browse thing)

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]opentable("Your Text"wink;
$result = dbquery("SELECT * FROM ".$db_prefix."news WHERE `news_cat`='1' ORDER BY news_datestamp DESC LIMIT 0,15"wink;
if (dbrows($result) != 0) {
while($data = dbarray($result)) {
$itemsubject = trimlink($data['news_subject'], 110);
echo "<img src='".THEME."images/bullet.gif'> <a href='".BASEDIR."news.php?readmore=".$data['news_id']."' class='hop'> ".$itemsubject."</a><br />
".showdate("%d-%m-%Y", $data['news_datestamp'])."<br />\n";
}
} else {
echo "No News";
}

closetable();[/syntaxhighlighter]
You mean like this? If not explain a bit more about what you're looking for

CodeDownload  
opentable("Your Text");
$result = dbquery("SELECT * FROM ".$db_prefix."news WHERE `news_cat`='1' ORDER BY news_datestamp DESC LIMIT 0,15");
if (dbrows($result) != 0) {
while($data = dbarray($result)) {
$itemsubject = trimlink($data['news_subject'], 110);
echo "<img src='".THEME."images/bullet.gif'> <a href='".BASEDIR."news.php?readmore=".$data['news_id']."' class='hop'> ".$itemsubject."</a>
".showdate("%d-%m-%Y", $data['news_datestamp'])."<br />".$data['news_news']."\n";
}
} else {
echo "No News";
}
 
closetable();



Regards
Robin
yeah like that but news image is not showing... i mean that place, when you click that tiny edit pen, and go to place where you can edit news, there you can browse/upload a picture to that news.

(sry for bad english) anyway, thanks for this and i actually think i know how im gonna do it now.
Okey try this. Edit image is not visible for members
CodeDownload  
opentable("Your Text");
$result = dbquery("SELECT * FROM ".$db_prefix."news WHERE `news_cat`='1' ORDER BY news_datestamp DESC LIMIT 0,15");
if (dbrows($result) != 0) {
while($data = dbarray($result)) {
$itemsubject = trimlink($data['news_subject'], 110);
echo "<img src='".THEME."images/bullet.gif'> <a href='".BASEDIR."news.php?readmore=".$data['news_id']."' class='hop'> ".$itemsubject."</a>
".showdate("%d-%m-%Y", $data['news_datestamp'])."";
if (checkrights("N")) {
echo "&nbsp;<a href='".ADMIN."news.php".$aidlink."&amp;action=edit&amp;news_id=".$data['news_id']."'><img src='".get_image("edit")."' alt='".$locale['global_076']."' title='".$locale['global_076']."' style='vertical-align:middle;border:0;' /></a></span>\n";
}
echo "<br />".$data['news_news']."\n";
}
} else {
echo "No News";
}

that's not what i meant, but that edit pen is a good plus too :) thank you for that.

what i meant is, when you click that edit pen, and then you can see that browse thing that allows you to upload a picture so it will show up in that news.

i meant THAT picture. I want that picture to show up when using this code. (just like normally news has pic for news category) im not sure but i think it is some kind of news_cat_image thing or something... but i don't mean news category -image , i mean that image that can be uploaded when editing news. I actually have it working in news.php (or i remember so) with news that are in my frontpage/newspage... but i don't know where it is. I actually did some time ago know where it is...
how to make news.php (main default news in front page) show news only from 1 category too?

i have to put that same code somewhere?

Quote

Darra wrote:
that's not what i meant, but that edit pen is a good plus too :) thank you for that.

what i meant is, when you click that edit pen, and then you can see that browse thing that allows you to upload a picture so it will show up in that news.

i meant THAT picture. I want that picture to show up when using this code. (just like normally news has pic for news category) im not sure but i think it is some kind of news_cat_image thing or something... but i don't mean news category -image , i mean that image that can be uploaded when editing news. I actually have it working in news.php (or i remember so) with news that are in my frontpage/newspage... but i don't know where it is. I actually did some time ago know where it is...


You should use this way:

CodeDownload  

opentable('Name your category');
$sql = dbquery("select * from ".$db_prefix."news where news_cat='2' order by news_datestamp DESC LIMIT 6");
$cnt = 0; $col = 2;
echo "<table cellpadding='0' cellspacing='0' width='100%' id='headline'>\n<tr>\n";
while($row = dbarray($sql)){
     if ($cnt != 0 && ($cnt % $col == 0)) { echo "</tr>\n<tr>\n"; }
      echo "<td valign='top' width='50%' class='tbl'><div class='somestyling'><img src='".IMAGES_N_T.$row['news_image_t2']."' width='100' height='69' />";
      echo "<div class='title'><a href='news.php?readmore=".$row['news_id']."'>".stripslashes($row['news_subject'])."</a></div></div></td>";
     $cnt++;
}
echo "</tr></table>";
closetable();

Quote

Darra wrote:
how to make news.php (main default news in front page) show news only from 1 category too?


First of all, Always take a Backup of the original file for future needs.

Open your news.php and you will find this Code on about Line 33 :

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$result = dbquery("SELECT tn.*, tc.*, tu.user_id, tu.user_name, tu.user_status FROM ".DB_NEWS." tn
LEFT JOIN ".DB_USERS." tu ON tn.news_name=tu.user_id
LEFT JOIN ".DB_NEWS_CATS." tc ON tn.news_cat=tc.news_cat_id
WHERE ".groupaccess('news_visibility'wink." AND (news_start='0'||news_start<=".time()."wink AND (news_end='0'||news_end>=".time()."wink AND news_draft='0'
ORDER BY news_sticky DESC, news_datestamp DESC LIMIT ".$_GET['rowstart'].",$items_per_page"
);[/syntaxhighlighter]

Now Replace this Code by :

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$result = dbquery("SELECT tn.*, tc.*, tu.user_id, tu.user_name, tu.user_status FROM ".DB_NEWS." tn
LEFT JOIN ".DB_USERS." tu ON tn.news_name=tu.user_id
LEFT JOIN ".DB_NEWS_CATS." tc ON tn.news_cat=tc.news_cat_id
WHERE ".groupaccess('news_visibility'wink." AND news_cat='Your Category ID Here' AND (news_start='0'||news_start<=".time()."wink AND (news_end='0'||news_end>=".time()."wink AND news_draft='0'
ORDER BY news_sticky DESC, news_datestamp DESC LIMIT ".$_GET['rowstart'].",$items_per_page"
);[/syntaxhighlighter]

Remember to Replace news_cat='Your Category ID Here' in the above code with your Category ID from which you want to show !
That was very very helpful! Thank both of you! working.
Ankur this works but the pagination is off, it shows the amount of pages all together even if the category has 1 news, I get 20+ pages..... Is there any other way to change maybe news_cat.php to show the entire news not just titles? I think that will be useful. Thanks

Quote

bale wrote:
Ankur this works but the pagination is off, it shows the amount of pages all together even if the category has 1 news, I get 20+ pages..... Is there any other way to change maybe news_cat.php to show the entire news not just titles? I think that will be useful. Thanks


Oh Yeah !!! I didn't saw that pfft

For that, you will find a line in starting of news.php defining no of rows :
[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$rows = dbcount("(news_id)", DB_NEWS, groupaccess('news_visibility'wink." AND (news_start='0'||news_start<=".time()."wink AND (news_end='0'||news_end>=".time()."wink AND news_draft='0'"wink;[/syntaxhighlighter]

Modify this line too to :

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]$rows = dbcount("(news_id)", DB_NEWS, groupaccess('news_visibility'wink." AND news_cat=Your_News_category_ID AND (news_start='0'||news_start<=".time()."wink AND (news_end='0'||news_end>=".time()."wink AND news_draft='0'"wink;[/syntaxhighlighter]
Thanks this works okay. I hope for the future the same thing can be implemented for news_cats.php. Just titles doesn't make sense
Oh i remembered something, this doesn't have pages so i can't use it yet. so how i will add pages to these news? i mean i don't have pages when i use this code. i think you can copy that page system from news.php but im not sure what and where to put it.

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<?php
$sql = dbquery("select * from ".$db_prefix."news where news_cat='18' order by news_datestamp DESC LIMIT 0,15"wink;
$cnt = 0; $col = 2;
echo "<table cellpadding='0' cellspacing='0' width='100%' id='headline'>n<tr>n";
while($row = dbarray($sql)){
if ($cnt != 0 && ($cnt % $col == 0)) { echo "</tr>n<tr>n"; }
echo "<td valign='top' class='tbl'><div class='title'>&nbsp;".stripslashes($row['news_subject'])."</div><table width='100%'><tr><td valign='top' style='border:1px solid #000000; padding:0px;'><a href='news.php?readmore=".$row['news_id']."'><img src='".IMAGES_N_T.$row['news_image_t2']."' width='100' height='69' border='0' /></a></td><td width='100%' valign='top' style='border:1px solid #000000; padding:5px;'> ".$row['news_news']." <a href='news.php?readmore=".$row['news_id']."'>...Read more</a>";
echo "</td></tr></table></td>";
$cnt++;
}
echo "</tr></table>";
?>[/syntaxhighlighter]

Quote

Darra wrote:

Oh i remembered something, this doesn't have pages so i can't use it yet. so how i will add pages to these news? i mean i don't have pages when i use this code. i think you can copy that page system from news.php but im not sure what and where to put it.


Are you trying to display it on separate page ? Then try adding this Code to a New Custom Page and see...
Yes i need pages to that same place where i show news from one category. It's that same code i just posted... i have that code in viewpage.php?page_id=6 if that's what you mean when you say separate page?

what you mean try adding that code to a new custom page? I think it is custom page because it's in viewpage.php?page_id=6
Ok ! So you are already using it in a Custom Page. So what is the problem now ?

I am not getting your point how i will add pages to these news? Please explain a bit more... It will be better if you will provide us a Site Link of it...
What i mean there is no pages like 1 2 ... 10 (example)

thats what i mean. i have 6 news there, but it shows all 6 news and it should show 5 news and then page two where is that 1 news. This works in news.php but now when im doing it in separate custom page, pages are not showing up.
Sorry for the Late Reply. You know college timings sux... sad

Anyways, Try this... I hope this may help you out... ;-)

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<?php

// Counting Totals
$result = dbquery("select * from ".DB_NEWS." where news_cat='13' order by news_datestamp"wink;
$rows=dbrows($result);

// Default Query
$your_range = 5;
$sql = dbquery("select * from ".DB_NEWS." where news_cat='13' order by news_datestamp DESC LIMIT ".$_GET['rowstart'].",$your_range"wink;

$cnt = 0;
$col = 2;

echo "<table cellpadding='0' cellspacing='0' width='100%' id='headline'>n<tr>n";
while($row = dbarray($sql)) {
if ($cnt != 0 && ($cnt % $col == 0)) { echo "</tr>n<tr>n"; }
echo "<td valign='top' class='tbl'><div class='title'>&nbsp;".stripslashes($row['news_subject'])."</div><table width='100%'><tr><td valign='top' style='border:1px solid #000000; padding:0px;'><a href='news.php?readmore=".$row['news_id']."'><img src='".IMAGES_N_T.$row['news_image_t2']."' width='100' height='69' border='0' /></a></td><td width='100%' valign='top' style='border:1px solid #000000; padding:5px;'> ".$row['news_news']." <a href='news.php?readmore=".$row['news_id']."'>...Read more</a>";
echo "</td></tr></table></td>";
$cnt++;
}
echo "</tr></table>";

// Making Page Navigation
if ($rows > 3) echo "<div align='center' style=';margin-top:5px;'>n".makepagenav($_GET['rowstart'],$your_range,$rows,3,FUSION_SELF."?page_id=".$_GET['page_id']."&amp;"wink."n</div>n";

?>[/syntaxhighlighter]

Set the value of $your_range to what no of news you want in one page(items per page)........
thank you, it's working! :)
Hello, I'm using this panel and I have a problem.
If I'm at home working perfectly. But if I log in he gets the link forum/

how can I fix this?

Thanks.
Thread Information
Author
Replies
25 posts
Views
9,064 times
Last Post
Last updated on 7 years ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: afaaro, PolarFox, DrunkeN, Ankur, Darra, bale, Evilkyo, nerkiuz