1
ralf57
Troubles showing the Last 10 News in xoops/admin.php
  • 2004/9/15 0:23

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


I need to show the "Last 10 News" table in xoops_install/admin.php file to replace the blank area
beside the modules logos.
I have "stolen" the required code from the
xoops_install/modules/news/admin/index.php file
and built a standalone file (last_news.php) which works fine.
If i include this file in xoops_install/admin.php
i get this error:

Fatal errorCall to a member function on a non-object in


I can't understand where this error comes from.
Is it possibile to get it working?
Any suggestion appreciated.
ATB,ralf.

2
ralf57
Re: Troubles showing the Last 10 News in xoops/admin.php
  • 2004/9/15 7:09

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


This "silence" makes me think it's not so easy to do

3
Mithrandir
Re: Troubles showing the Last 10 News in xoops/admin.php

Sure, it's easy, but as I don't know your code, it is rather difficult to say where the problem lies.

The error is due to a call to an object method on a variable, which is not an object - why the variable is not an object, I cannot say before seeing the code.

4
ralf57
Re: Troubles showing the Last 10 News in xoops/admin.php
  • 2004/9/15 12:40

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


You're right Mith.
This is the code of last_news.php
<?php 
//include '../../include/cp_header.php';
include_once XOOPS_ROOT_PATH "/class/xoopstopic.php";
include_once 
XOOPS_ROOT_PATH "/class/xoopslists.php";
include_once 
XOOPS_ROOT_PATH "/modules/news/class/class.newsstory.php";



/*
 * Shows last 10 published stories
 */
function lastStories()
{
    global 
$xoopsDB$xoopsConfig$xoopsModule;
    echo
"<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class="odd">";
    echo 
"<div style='text-align: center;'><b>" _AM_LAST10ARTS "</b><br />";
    
$storyarray NewsStory :: getAllPublished1000);
    echo 
"<table border='1' width='50%'><tr class='bg3'><td align='center'>" _AM_STORYID "</td><td align='center'>" _AM_TITLE "</td><td align='center'>" _AM_TOPIC "</td><td align='center'>" _AM_POSTER "</td><td align='center' class='nw'>" _AM_PUBLISHED "</td><td align='center' class='nw'>" _AM_EXPIRED "</td><td align='center'>" _AM_ACTION "</td></tr>";
    foreach( 
$storyarray as $eachstory )
    {
        
$published formatTimestamp$eachstory -> published() );
        
$expired = ( $eachstory -> expired() > ) ? formatTimestamp$eachstory -> expired() ) : '---';
        
$topic $eachstory -> topic();
        echo 
"
            <tr><td align='center'><b>" 
$eachstory -> storyid() . "</b>
            </td><td align='left'><a href='" 
XOOPS_URL "/modules/" $xoopsModule -> dirname() . "/article.php?storyid=" $eachstory -> storyid() . "'>" $eachstory -> title() . "</a>
            </td><td align='center'>" 
$topic -> topic_title() . "
            </td><td align='center'><a href='" 
XOOPS_URL "/userinfo.php?uid=" $eachstory -> uid() . "'>" $eachstory -> uname() . "</a></td><td align='center' class='nw'>" $published "</td><td align='center'>" $expired "</td><td align='center'><a href='" XOOPS_URL "/modules/news/admin/index.php?op=edit&storyid=" $eachstory -> storyid() . "'>" _AM_EDIT "</a>-<a href='" XOOPS_URL "/modules/news/admin/index.php?op=delete&storyid=" $eachstory -> storyid() . "'>" _AM_DELETE "</a>";
        echo 
"</td></tr>n";
    } 
    echo 
"</table><br />";
    echo 
"<form action='index.php' method='post'>
        " 
_AM_STORYID " <input type='text' name='storyid' size='10' />
        <select name='op'>
        <option value='edit' selected='selected'>" 
_AM_EDIT "</option>
        <option value='delete'>" 
_AM_DELETE "</option>
        </select>
        <input type='submit' value='" 
_AM_GO "' />
        </form>
    </div>
        "
;
    echo
"</td></tr></table>";

 
        
//xoops_cp_header();
        //echo "<h4>" . _AM_CONFIG . "</h4>";
        
include_once XOOPS_ROOT_PATH "/class/module.textsanitizer.php"
        
// $xoopsModule->printAdminMenu();
        // echo "<br />";
        
lastStories();
        echo 
"<br />";
        echo
"<table width='100%' border='0' cellspacing='1' class='outer'><tr><td class="odd">";
        echo
"all articvle";
        echo
"</td></tr></table>";
        
//xoops_cp_footer();

?>


and i placed it in xoops_install/modules/system/ folder.

This file works fine (aexcept for the lang defines)if included in
xoops_install/modules/system/admin.php
with this line:
include XOOPS_ROOT_PATH "/modules/system/last_news.php";


The same file gives me the error reported in my first post
if it's included in
xoops_install/admin.php
Hope i was more clear now and you can help.

5
hervet
Re: Troubles showing the Last 10 News in xoops/admin.php
  • 2004/9/15 12:55

  • hervet

  • Friend of XOOPS

  • Posts: 2267

  • Since: 2003/11/4


Hi,

Quote:

ralf57 wrote:
I need to show the "Last 10 News" table in xoops_install/admin.php file to replace the blank area
beside the modules logos.

The easier is to use the news module by itself...

Quote:

I have "stolen" the required code from the
xoops_install/modules/news/admin/index.php file
and built a standalone file (last_news.php) which works fine.
If i include this file in xoops_install/admin.php
i get this error:

Yop .. "I have stolen" .... that's not what i will say !

Quote:

I can't understand where this error comes from.

Don't copy/paste code without knowing how it runs.

1) When you report a message, report it completly
2) Specify the version of the news module
3) See the line indicated by the error message and try to "investigate" what's needed.
4) Some files are required by the news module, for example see the file named /xoops/modules/news/index.php, at the top (there are some files included)


Bye,
Hervé



6
ralf57
Re: Troubles showing the Last 10 News in xoops/admin.php
  • 2004/9/15 15:14

  • ralf57

  • Quite a regular

  • Posts: 231

  • Since: 2003/2/3 1


@hervet
Thank you for your tips.
I'll make threasure of them.
Quote:
Don't copy/paste code without knowing how it runs


It's by copying and pasting that i have learned all that i know about xoops.
This method works for me...

7
Mithrandir
Re: Troubles showing the Last 10 News in xoops/admin.php

What line is the error in?
What does the corresponding line look like?

I'm afraid I must agree with Hervé - it helps to understand the elements, you use.

You use $xoopsModule - but you place the file in system. And include it in... what was it? root/admin.php?

$xoopsModule is IIRC not defined at that point, so there is no object.

remove $xoopsModule from the "global $xoopsConfig..." line and add this right after that global statement:
$module_handler =& xoops_gethandler('module');
$xoopsModule =& $module_handler->getByDirname('news');

Login

Who's Online

163 user(s) are online (77 user(s) are browsing Support Forums)


Members: 0


Guests: 163


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits