Welcome, Guest. Please login or register.
Did you miss your activation email?
May 16, 2012, 09:53:42 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155094 Posts in 21661 Topics by 7721 Members
Latest Member: arrow345
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: News module: 2 headlines (with readmore) and the rest as a list (possible?)  (Read 3629 times)
Woudloper
Guest
« on: November 26, 2005, 09:39:58 AM »

Is it possible to make the news page display something as illustrated down below?
Quote
News title 1
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam porta fermentum augue. Etiam mi nunc, mollis eu, laoreet ac, condimentum in, eros. Nullam venenatis velit et est. Nullam ullamcorper mi posuere lacus. Nulla tincidunt sem. Sed vitae ligula vel lectus consectetuer sollicitudin.

» Read more
News title 2
Aliquam rhoncus turpis ullamcorper nisl. Praesent posuere, arcu non volutpat interdum, lacus lectus sollicitudin erat, sit amet pulvinar arcu orci sit amet dui. Aenean sollicitudin ultricies nulla. Aenean sit amet dui nec pede tristique lacinia. Donec condimentum augue eu leo. Mauris eleifend. Nunc venenatis volutpat nulla. Duis ultricies. Duis a pede.

» Read more

datesubjectlink
22-02-2005News title 3Link
22-03-2005News title 4Link
22-04-2005News title 5Link
22-05-2005News title 6Link

What I would like to do is list only for the first two news items more information and for all other newsitems I only want to list them in a table...

Hope someone can explain me how I can make this possible. Can this only be done with the news module? Or should I work with a combination of a code page and the news headlines code snippet!? Hope someone can explain me how I can make this possible...
Logged
i2Paq

Offline Offline

Posts: 510


« Reply #1 on: November 26, 2005, 11:59:39 AM »

Wauw! This would be a great module!
Logged

Opensource is my life, but then elsewhere.
Woudloper
Guest
« Reply #2 on: November 27, 2005, 04:25:07 PM »

Wauw! This would be a great module!

Yes, that where my thoughts exactly. But would something like this be possible to get it working with the current version of the module e.g. together with the newsreader code snippet  huh Hope someone can help me out with this...
Logged
i2Paq

Offline Offline

Posts: 510


« Reply #3 on: November 27, 2005, 06:21:04 PM »

I'm a n00b in writing php, all I can do is test  cool
Logged

Opensource is my life, but then elsewhere.
pcwacht
Guest
« Reply #4 on: November 27, 2005, 10:07:11 PM »

I'm not a wiz either, but..... Tongue


Just change the output to your likings....

make a codesection in it paste:
Code:
// Specify the Group(id) you want to read the news from or 0 for all groups
$group = 0;       

// Specify number of newsitems                       
$limit=10;

// Specify read more text
$readmore = "Read more";       

// Specify Older news text
$oldernews = "Older news";       

// Query for obtaining stuff from a group
$query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = $group and active = 1 ORDER BY position DESC LIMIT 0, 10;";

// Query for all groups ;)
if ($group<1 ) {
  $query = "SELECT * FROM ".TABLE_PREFIX."mod_news_posts WHERE active = 1 ORDER BY position DESC LIMIT 0, 10;";
}

// No changes needed here, maybe for output!

global $database;

$result = $database->query($query);
$total = $result->numRows();       // how many items are there?

if ($total>1) {                                // at least 2 needed for 2 news items
  $data = $result->fetchRow() ;    // get left item
  $data2 = $result->fetchRow() ;  // get right item
  echo '<table width=100%>';
  echo '<tr><td width=50%>'.$data['title'].'</td><td width=50%>'.$data2['title'].'</td></tr>';
  echo '<tr><td>'.$data['content_short'].'</td><td>'.$data2['content_short'].'</td></tr>';
  echo '<tr><td></td><td></td></tr>';
  echo '<tr><td><a href="'.WB_URL.PAGES_DIRECTORY.$data['link'].PAGE_EXTENSION.'">'.$readmore.'</a></td>';
  echo '<td><a href="'.WB_URL.PAGES_DIRECTORY.$data2['link'].PAGE_EXTENSION.'">'.$readmore.'</a></td></tr>';
  echo '</table>';
}

// Next show the rest
if ($total>2) {                                // are there any left?
echo '<br><br><table><tr><td colspan=2>'.$oldernews.'</td></tr>';
echo '<tr><td>Date</td><td>Subject</td></tr>';
while ($data = $result->fetchRow()) { 
  echo '<tr><td>'.strftime( "%d-%m-%Y",$data['posted_when']).'</td>';
  echo '<td><a href="'.WB_URL.PAGES_DIRECTORY.$data['$link'].PAGE_EXTENSION.'">'.$data['title'].'</a></td></tr>';
}
echo '</table>';
}

Is this what you need?

John
« Last Edit: November 27, 2005, 10:34:41 PM by pcwacht » Logged
macsmet

Offline Offline

Posts: 233


« Reply #5 on: June 02, 2006, 09:04:28 PM »

Hi there,

This is my first post because I just discoverd WB last week. I really love it and I'm working on my first WB site right now.
I was looking for something like this news option myself so I was very happy I found it but I ran into a little trouble.

The first part of the suggested code works but the news list with the older news doesn't.
The link sends me to ./wb/pages.php and not to the related news.
I just copied the code and didn't change anything.

Can someone help me with this?
I don't know how to change it myself.

Greeting,

MacSmet
From a rather cold Holland (for the time of the year!)
Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6974


WWW
« Reply #6 on: June 02, 2006, 11:41:30 PM »

that is not hard ...

look at this line:
Code:
  echo '<td><a href="'.WB_URL.PAGES_DIRECTORY.$data['$link'].PAGE_EXTENSION.'">'.$data['title'].'</a></td></tr>';

The fault lies in the link, there is a "$" too much. Change this line near the botom of the page to:
Code:
  echo '<td><a href="'.WB_URL.PAGES_DIRECTORY.$data['link'].PAGE_EXTENSION.'">'.$data['title'].'</a></td></tr>';
and you are all ready to go ...

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

macsmet

Offline Offline

Posts: 233


« Reply #7 on: June 03, 2006, 10:42:22 AM »

Hi Klaus,

That was really easy!
Like I said: i'm new to this and couldn't find the solution myself.
Thanks!

As a hobby I used to work with HTML for nearly 10 years now and now discovering much more the power of XHTML and CSS. SQL and PHP is fairly new to me. I also like real programming with Runtime Revolution (cross platform).
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!