Members: 16,996
Threads: 38,845
Posts: 159,389
Online: 15

Newest Member: Kl_broka@rediffmail.com


Odoo.tv - Outdoor Television


Sedo - Domains kaufen und verkaufen das Projekt mambers.com steht zum Verkauf Besucherstatistiken von mambers.com etracker® Web-Controlling statt Logfile-Analyse

Go Back   Mambers.com > Development > Module Development

Reply
 
LinkBack Thread Tools Display Modes
Old 18.04.2004, 14:49   #1 (permalink)
Baby Mamber
 
Join Date: Apr 2004
Posts: 8
Dragon4678 is on a distinguished road
Default I need to change the amount of displayed items.

I'm using a premade CMS that I'm not too familiar with. Its really good (Mambo OS), but I need a little bit of help.



I've got a script that is loading a list of objects from a specific database table, and then displaying only 1 item, at random.



Now, what I'm trying to do is get this same script to display the last five added items, with the newest at the top of the list, one on top of another, with a limit of 4 items. Each item needs to have its own, but repeating for each, table layout.



Here is the original code:

PHP Code:
 <?php

/// $Id: mod_newsflash3.php,v 1.7 2003/12/03 20:56:34 rcastley Exp $

/**

* newsflash3 Module

* @package Mambo Open Source

* @Copyright (C) 2000 - 2003 Miro International Pty Ltd

* @ All rights reserved

* @ Mambo Open Source is Free Software

* @ Released under GNU/GPL License : [url]http://www.gnu.org/copyleft/gpl.html[/url]

* @version $Revision: 1.7 $

**/

defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global 
$gid$mosConfig_offset;

// load the html drawing class, MUST include the option for components

//require_once( $mainframe->getPath( 'front_html', 'com_newsflash3' ) );

$access = !$mainframe->getCfg'shownoauth' );

$now date"Y-m-d H:i:s"time()+$mosConfig_offset*60*60 );

$database->setQuery"SELECT COUNT(*) AS numrows"

."\nFROM #__newsflash3"

."\nWHERE published=1"

."\nAND access <= $gid "

."\nAND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now') "

."\nAND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now')"

);

$numrows $database->loadResult();

if (
$numrows 1) {

mt_srand( (double) microtime()*1000000 );

$flashnum mt_rand0, --$numrows );

} else {

$flashnum 0;

}

$database->setQuery"SELECT content"

."\nFROM #__newsflash3"

."\nWHERE published=1"

."\nAND access <= $gid "

."\nAND (publish_up = '0000-00-00 00:00:00' OR publish_up <= '$now') "

."\nAND (publish_down = '0000-00-00 00:00:00' OR publish_down >= '$now')"

."\n LIMIT $flashnum,1"

);

$row null;

if (
$database->loadObject$row )) {

newsflash3_html::Writenewsflash3$row );

}

class 
newsflash3_html {

function 
Writenewsflash3( &$row ) {

?>

<td width="2" rowspan="7"><font color="#F2F2F2" style="font-size: 2px">.</font></td>

<td width="209" height="275" rowspan="7" bgcolor="#8BA2B4" style="padding-top: 6px" valign="top">

<img src="<?php echo $mosConfig_live_site;?>/templates/default/images/edcor.jpg" width="209" height="5" style="margin-bottom: 31px">

<center><img src="<?php echo $mosConfig_live_site;?>/templates/default/images/editorial.jpg" width="191" height="89" style="border: 4px solid white; margin-bottom: 18px"></center>

<p class="hfeat" style="font-size: 10px; color: white; margin-left: 11px; margin-right: 11px; margin-bottom: 28px">

<?php echo $row->content?>

</p></td>

<?php

}

}

?>


Ok, and here is an example of another script in the same cms, that does what I am trying to do (gets items, displayes them in order), but I can't seem to get my *version* of the hacked code to work.



PHP Code:
<?php

//Section Latest News Module//

// $Id: mod_SectionLatestNews.php,v 1.0b 2004/01/20 by Tony Lightfoot based upon mod_latestnews.php by rcastley Exp $

/**

* Section Latest News Module

* @package Mambo Open Source

* @Copyright (C) 2000 - 2003 Miro International Pty Ltd

* @ All rights reserved

* @ Mambo Open Source is Free Software

* @ Released under GNU/GPL License : [url]http://www.gnu.org/copyleft/gpl.html[/url]

* @version $Revision: 1.0b $

**/

/**

* Section Latest News Module

*Displays the news queued to be published. 

*/

// following line is to prevent direct access to this script via the url

defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

global 
$mosConfig_offset;

$count = @$params->count intval$params->count ) : 5;

$now date"Y-m-d H:i:s"time()+$mosConfig_offset*60*60 );

 

$query "SELECT c.id, c.name, a.id, a.title, a.sectionid, a.catid"

"\nFROM #__content AS a, #__categories AS c"

    
"\nWHERE ( c.id = a.catid AND a.state='1' AND a.sectionid > '0' AND a.checked_out='0' )"

    
"\n AND (a.publish_up = '0000-00-00 00:00:00' OR a.publish_up <= '$now')"

"\n AND (a.publish_down = '0000-00-00 00:00:00' OR a.publish_down >= '$now')"

    
. ($catid "\n AND a.catid='$catid'" '')

    . 
"\nORDER BY created DESC LIMIT $count";

// initialise the query in the $database connector

// this translates the '#__' prefix into the real database prefix

$database->setQuery$query );

// retrieve the list of returned records as an array of objects

$rows $database->loadObjectList();

// cycle through the returned rows displaying them in a table

// with links to the content item

// escaping in and out of php is now permitted

?>

<table cellpadding="1" cellspacing="1" border="0">

<?php foreach ($rows as $row) { ?>

<tr>

        <td valign="top"><img border="0" src="<?php echo $mosConfig_live_site;?>/images/M_images/arrow.png"></td>

<td><strong><a href="<?php echo sefRelToAbs("index.php?option=content&amp;task=view&amp;id=$row->id"); ?>"><?php echo $row->title;?></a></strong><br><a href="<?php echo sefRelToAbs("index.php?option=content&task=category&sectionid=$row->sectionid&id=$row->catid"); ?>"><?php echo $row->name;?></a></td>

</tr>

 

<?php

}

?>

</table>


Could anyone help me please?



Any help at all is greatly appreciated. Thanks.
Dragon4678 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Old 18.04.2004, 20:17   #2 (permalink)
Expert Mamber
 
keliix06's Avatar
 
Join Date: Mar 2004
Posts: 202
keliix06 is on a distinguished road
Send a message via MSN to keliix06
Default Re: I need to change the amount of displayed items.

Changfe this line
PHP Code:
."\n LIMIT $flashnum,1" 
to
PHP Code:
."\n LIMIT $flashnum,4" 
keliix06 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Events Component -> Unable to edit/selected created Category reactive Component 'How Do I' Questions 25 21.02.2005 13:38
How do I... Change the default Display # in a content section? sh33zo Mambo 4.5 'How Do I' Questions 9 25.08.2004 01:18
Change Date Display at Frontpage dingin Mambo 4.5 'How Do I' Questions 5 14.04.2004 12:08
How to link content items to main menu afru Mambo 4.5 'How Do I' Questions 3 11.04.2004 16:16
How do I change the number of items that the Content Category shows in one page? reele Mambo 4.5 'How Do I' Questions 3 09.04.2004 05:42


All times are GMT +2. The time now is 08:23.

Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0
A vBSkinworks Design
© Copyright 2004-2008 by Arthur Konze Webdesign.