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
//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
"odd">";
    echo 
"_AM_LAST10ARTS ""
;
    
$storyarray NewsStory :: getAllPublished1000);
    echo 
"_AM_STORYID "_AM_TITLE "_AM_TOPIC "_AM_POSTER "_AM_PUBLISHED "_AM_EXPIRED "_AM_ACTION "";
    foreach( 
$storyarray as $eachstory )
    {
        
$published formatTimestamp$eachstory -> published() );
        
$expired = ( $eachstory -> expired() > ) ? formatTimestamp$eachstory -> expired() ) : '---';
        
$topic $eachstory -> topic();
        echo 
"
            
$eachstory -> storyid() . "
            XOOPS_URL "/modules/" $xoopsModule -> dirname() . "/article.php?storyid=" $eachstory -> storyid() . "'>" $eachstory -> title() . "
            
$topic -> topic_title() . "
            XOOPS_URL "/userinfo.php?uid=" $eachstory -> uid() . "'>" $eachstory -> uname() . "$published "$expired "XOOPS_URL "/modules/news/admin/index.php?op=edit&storyid=" $eachstory -> storyid() . "'>" _AM_EDIT "-XOOPS_URL "/modules/news/admin/index.php?op=delete&storyid=" $eachstory -> storyid() . "'>" _AM_DELETE "";
        echo 
"n";
    } 
    echo 
"";
    echo 
"
        " 
_AM_STORYID 
        
        
_AM_EDIT "
        
_AM_DELETE "
        
        _AM_GO "' />
        
    

        ";
    echo
"";

 
        
//xoops_cp_header();
        //echo "

" . _AM_CONFIG . "

";
        
include_once XOOPS_ROOT_PATH "/class/module.textsanitizer.php"
        
// $xoopsModule->printAdminMenu();
        // echo "";
        
lastStories();
        echo 
"";
        echo
"odd">";
        echo
"all articvle";
        echo
"";
        
//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

373 user(s) are online (118 user(s) are browsing Support Forums)


Members: 0


Guests: 373


more...

Donat-O-Meter

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

Latest GitHub Commits