Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS /

Infinite request loop with growing page tree in CMS backend after adding a new page type


Reply


2 Posts   768 Views

Avatar
rrva

Community Member, 4 Posts

26 February 2011 at 10:48pm

Edited: 26/02/2011 10:49pm

I am new to silverstripe and just tried to add a new page type which will allow me to fetch content from a remote page.

So, I added the following to mysite/code/RemoteContentPage.php

<?php
class RemoteContentPage extends Page {
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->replaceField('Content', new TextField('Content', 'URL to Remote Content')); // we abuse the content Field now to save the URL, we could do another DB Field, but since we already have Content ...
}
function Content() {
$Text = 'hejsan paag';
return $Text;
}
}
class RemoteContentPage_Controller extends Page_Controller {
}
?>

Then I ran /dev/build?flush=1 and tried to create a new remote content page.

Here the backend crashed and I received an alert box that something went wrong (what was not visible in any apache log files).

After that I refreshed the backend by reloading my browser and now the backend page tree menu started to grow indefinitely, adding empty rows to itself and then performing a new request in a infinite loop.

When I removed RemoteContentPage.php from mysite/code and ran /dev/build again, remoteContentPage was still available in the /dev/build output and the backend crashes in the same way. Logout/Login from the backend did not help either.

Will clear all cookies and retry. What did I do wrong when trying to add a new page type?

Avatar
rrva

Community Member, 4 Posts

27 February 2011 at 2:09am

The problem was that

getCMSFields() did not return any value.

Adding

return $fields;

at the end of the function made it all work again.