What changes gets the pagedata for 1.7?

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
Post Reply
svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

What changes gets the pagedata for 1.7?

Post by svasti » Fri Jul 31, 2015 6:57 pm

Hi all,
I am just trying to fix some plugins for 1.7 and php 7. Wow, that's really complicated. Morepagedata throughs out numberless errorcodes:
1.7 on php7 wrote:#3 {main} thrown in C:\Users\ziesing\Downloads\CMSimple\Programm\Portable_XH-2.0dev2\Portable_XH\www\plugins\morepagedata\funcs.php on line 64
This seems to be the main culprit. Line 64 has

Code: Select all

foreach ($pd_router->model->params as $pd_var) { 
is this still valid?

Edit: Typos

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: What changes gets the pagedata for 1.7?

Post by cmb » Sat Aug 01, 2015 10:51 am

Um, do you only get this error message? :? When I put similar code into userfuncs.php, I get:
Fatal error: Uncaught Error: Cannot access protected property XH\PageDataRouter::$model in C:\Users\cmb\Portable_XH\www\cmsimple\userfuncs.php:3 Stack trace: #0 C:\Users\cmb\Portable_XH\www\cmsimple\cms.php(1038): include_once() #1 C:\Users\cmb\Portable_XH\www\index.php(10): include('C:\\Users\\cmb\\Po...') #2 {main} thrown in C:\Users\cmb\Portable_XH\www\cmsimple\userfuncs.php on line 3
That means you can't access $pd_router->model, because that property is not part of the public API (and actually never should have been, but PHP 4 didn't allow to specify that). Instead you can call $pd_router->storedFields(), which should basically return the same info. For backward compatibility with XH < 1.6 you can write a small wrapper function, for instance:

Code: Select all

function getPageDataFields()
{
    global $pd_router;
  
    if (method_exists($pd_router, 'storedFields')) {
        return $pd_router->storedFields();
    } else {
        return $pd_router->model->params;
    }
} 
Or simply inline the code.
Christoph M. Becker – Plugins for CMSimple_XH

svasti
Posts: 1659
Joined: Wed Dec 17, 2008 5:08 pm

Re: What changes gets the pagedata for 1.7?

Post by svasti » Sat Aug 01, 2015 2:27 pm

Ah yeah, that helps.
I wonder however if compatibility to XH 1.5 would be necessary? Usually people with older installations don't plan adding new tricks, I guess. Anyhow, I've implemented your suggestion.

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: What changes gets the pagedata for 1.7?

Post by cmb » Sun Aug 02, 2015 1:31 pm

svasti wrote:I wonder however if compatibility to XH 1.5 would be necessary? Usually people with older installations don't plan adding new tricks, I guess.
And unfortunately, they might not update core and plugins anyway.
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply