Jump to content

Trouble getting CMS record


Go to solution Solved by Daniel F,

Recommended Posts

Posted

Hello,

I'm trying to get a CMS record in a custom PHP script using:

\IPS\cms\Records::loadFromSlug($id, false);

But I am getting the following error:
 

Quote

BadMethodCallException:  (0)
#0 /applications/cms/sources/Records/Records.php(1688): IPS\Content\_Item->container()
#1 /system/Patterns/ActiveRecord.php(335): IPS\cms\_Records->get__forum_record()
#2 /applications/cms/sources/Records/Records.php(1547): IPS\Patterns\_ActiveRecord->__get('_forum_record')
#3 /applications/cms/sources/Records/Records.php(2038): IPS\cms\_Records->__get('_forum_record')
#4 /applications/cms/sources/Records/Records.php(176): IPS\cms\_Records->useForumComments()
#5 /applications/cms/sources/Records/Records.php(345): IPS\cms\_Records::constructFromData(Array)

The problem seems to be when this gets executed:

$this->container()->forum_override

I don't know what the issue could be. Any ideas?

  • Solution
Posted

Don't forget that Records "doesn't exist", it's just a virtual class used to create the real implementation aka Records1, Records2 ( the Database ID is attached to the classname), this means you need to use the proper record class name. Instead of \IPS\cms\Records it's going to be \IPS\cms\Records1 ( replace 1 with your database id ) 

 

Posted
8 minutes ago, Daniel F said:

Don't forget that Records "doesn't exist", it's just a virtual class used to create the real implementation aka Records1, Records2 ( the Database ID is attached to the classname), this means you need to use the proper record class name. Instead of \IPS\cms\Records it's going to be \IPS\cms\Records1 ( replace 1 with your database id ) 

 

Thanks Daniel! Looks to be working now 🙇‍♂️

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...