11
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/19 0:48

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


The class and file name must follow the convention I pointed before.
That code cannot work neither on module or root.

12
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/19 12:27

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


so it should be corrected:
class xnewsnw_storiesHandler extends XoopsPersistableObjectHandler
{
    function 
__construct($db)
    {
        
parent::__construct($db'nw_stories''nw_stories'"storyid""title");
        
$this->className 'nw_NewsStory';
    }
}

13
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/19 14:03

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


That code must be in file xnews/class/nw_stories.php, and for good convention, the class name should be XnewsNw_storiesHandler.

I suggest you to paste all the code from xnews/class/class.newsstory.php into xnews/class/nw_stories.php, then put an include statement on old file to include the new one.

14
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/19 19:04

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


with this method gives me this error:

Fatal error: Call to undefined method nw_NewsStory::assignVars() in C:\wamp\www\xoops-2.5.3\htdocs\class\model\read.php on line 74

15
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/19 20:24

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Hum, yes. That is why we are deprecating XoopsStory class.

You should make nw_NewsStory extend from XoopsObject, use initVars() and copy methods from XoopsStory into nw_NewsStory.


16
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/20 11:47

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


ok no errors, but no data is taken from the database. The thing that I do not understand is that the function xoops_getmodulehandler uses different parameters than the manufacturer XoopsObject, or I did not yet understand the exact procedure.

17
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/22 10:40

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


The function
xoops_loadLanguage('homepage'$xoopsConfig['startpage']);
take only the modules and themes?

For root folder of language, as a method to make for index.php in root?

In this way does not work!

18
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/22 11:53

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Quote:

timgno wrote:
The function
xoops_loadLanguage('homepage'$xoopsConfig['startpage']);
take only the modules and themes?

For root folder of language, as a method to make for index.php in root?

In this way does not work!


I don't understand your english :(

xoopsLoadlanguage is for loading modules and core language.
You can use:
xoops_loadLanguage('main', 'news'); to load modules/news/language/english/main.php
or
xoops_loadLanguage('user); to load language/english/user.php

In xoops 2.6 you can get language from other folders like themes, Frameworks, etc (thanks to zyspec)

Quote:

ok no errors, but no data is taken from the database. The thing that I do not understand is that the function xoops_getmodulehandler uses different parameters than the manufacturer XoopsObject, or I did not yet understand the exact procedure.

xoops_getmodulehandler() is just a factory for the handlers (that handle the objects). It will return an instance of the handler class. The handler class must call it's parent XoopsObjectPersitableHandler class __construct() providing the parameters such as, the db table it will get data from, and the object class name that it will use to create a new object and populate with the data retrieved.

If you shared the code it would be easier to see the problem.

19
timgno
Re: Xoops 2.5.x Functions
  • 2011/11/22 12:20

  • timgno

  • Module Developer

  • Posts: 1504

  • Since: 2007/6/21


Quote:

trabis wrote:
I don't understand your english :(

xoopsLoadlanguage is for loading modules and core language.
You can use:
xoops_loadLanguage('main', 'news'); to load modules/news/language/english/main.php
or
xoops_loadLanguage('user); to load language/english/user.php

In xoops 2.6 you can get language from other folders like themes, Frameworks, etc (thanks to zyspec)


You understand perfectly from what you have written to me.

The problem is that if you use a file created by me in language/italian/homepage.php taken by the function:
xoops_loadLanguage('homepage');

does not work, only if I use the main.php of theme, it works


Quote:

xoops_getmodulehandler() is just a factory for the handlers (that handle the objects). It will return an instance of the handler class. The handler class must call it's parent XoopsObjectPersitableHandler class __construct() providing the parameters such as, the db table it will get data from, and the object class name that it will use to create a new object and populate with the data retrieved.

If you shared the code it would be easier to see the problem.


Begin on class nw_NewsStory:
I have changed
class nw_NewsStory extends [b]XoopsStory[/b]
{

with:
class nw_NewsStory extends [b]XoopsObject[/b]
{

as you said by replacing the class name as the instance nw_stories

The class handler is:
class xnewsnw_NewsStoryHandler extends XoopsPersistableObjectHandler
{
    function 
__construct($db)
    {
        
parent::__construct($db'nw_stories''nw_NewsStory'"storyid""title");
        
$this->className 'nw_NewsStory';
    }
}

This is correct?

The code in homepage.php is:
$nw_storiesHandler =& xoops_getModuleHandler('nw_stories''xnews');
$criteria = new CriteriaCompo();
$criteria->setSort("storyid");
$criteria->setOrder("DESC");
$nwrows $nw_storiesHandler->getCount();
if (isset(
$_REQUEST['limit'])) {
     
$criteria->setLimit($_REQUEST['limit']);
     
$limit $_REQUEST['limit'];
    
//$GLOBALS['xoopsTpl']->assign('xnews_limit', $limit);

$nw_stories_arr $nw_storiesHandler->getAll($criteria);
if (
$nwrows>0)
{
    foreach (
array_keys($nw_stories_arr) as $i)
    {
         
$xnews_title $nw_stories_arr[$i]->getVar("title");
         
$xnews_description $nw_stories_arr[$i]->getVar("description");
         
$xnews_picture $nw_stories_arr[$i]->getVar("picture");
     
$GLOBALS['xoopsTpl']->append('last_news', array('title' => $xnews_title
                                                         
'description' => $xnews_description
                                                         
'picture' => $xnews_picture));
    }
}

the variable picture will be taken from the class nw_topics

For file system_homepage.html:
<{$last_news.picture}>
<{
$last_news.title}>
<{
$last_news.description}>


I hope you understand

20
trabis
Re: Xoops 2.5.x Functions
  • 2011/11/22 13:32

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


The naming convention is not good, should be:
XnewsNw_newsStoryHandler and
Nw_NewsStory

but that is not the problem, php will understand it the same way.

The problem is that you forgot to use iniVar() in the Nw_NewsStory constructor.
Look into other classes to see how that is done.

Login

Who's Online

358 user(s) are online (298 user(s) are browsing Support Forums)


Members: 0


Guests: 358


more...

Donat-O-Meter

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

Latest GitHub Commits