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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Widgets /

Discuss SilverStripe Widgets.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

single content widget depreciated: SOLVED


Go to End


5 Posts   2300 Views

Avatar
w1l

Community Member, 13 Posts

9 December 2012 at 7:02pm

Hi Guys

I get this error (growl) when trying to open a page with this widget running (SS3.0.2)

Notice at line 168 of /nfs/c03/h01/mnt/81833/domains/youthguarantee.net.nz/html/framework/dev/Deprecation.php

Does anyone know how to fix this? My guess is theres something wrong in the php file:

<?php
/**
 * Widget to display a single Page Content
 * @package widgets.singlecontent
 * @author Rui Godinho
 */ 
class SingleContentWidget extends Widget {
	static $title = '';
	static $cmsTitle = 'Single Content';
	static $description = 'Adds content from a child page to the widget sidebar.';
	
	static $db = array(
		'WidgetTitle' => 'Varchar(255)',
		'SinglePage'=>'Varchar(255)'
		);
	static $defaults = array(
		'SinglePage'=>'home'
		);
	
	function Title() {
		return $this->WidgetTitle ? $this->WidgetTitle : self::$title;
	}
 
	function getCMSFields() {
		// TODO: Usar TreeDropdownField when bug fixed
		return new FieldSet(
			new TextField('WidgetTitle', _t('TITLE','Title (optional)')),
			new TextField('SinglePage', _t('SINGLEPAGE', 'The URL segment of the page to display.'))
		);
	}
	
	/**
	 * Return a Single Content Page
	 * @return DataObject
	 */
	function SingleContent() {
		$page = DataObject::get_one('SiteTree', "URLSegment = '". Convert::raw2sql($this->SinglePage) . "'");
		if(!$page) {
			return false;
		}
		else {
			return $page;
		}
	}
}

thanks all.
/w

Avatar
w1l

Community Member, 13 Posts

10 December 2012 at 8:07am

2 things to add to this:

1) The widgets works ok on my local site (MAMP) which uses PHP5.3.6
2) The hosting server is using PHP5.3.15

I see that Silverstripe says the min requirements to run is PHP5.3.2 - could this be the problem i wonder?

Avatar
w1l

Community Member, 13 Posts

10 December 2012 at 1:21pm

OK so its not the PHP ... I've now deployed to server running PHP5.3.3.7 and the problem persists.

/w

Avatar
(deleted)

Community Member, 473 Posts

10 December 2012 at 1:58pm

The error message will tell you that FieldSet is deprecated and you should use FieldList instead (in your getCMSFields() methods). This will only show when using a site in dev mode and with your php.ini settings display_errors to On.

Avatar
w1l

Community Member, 13 Posts

15 December 2012 at 8:37pm

Edited: 15/12/2012 8:37pm

OK so the problem was fixed in the end buy taking out a bunch of customisations in the _config file, not by changing the Content widget at all.

The config file is now stripped right back to the original fresh instal version and all seems OK.

Thanks for the info on dev mode though Simon, goona need to employ that now re my next problem (http://www.silverstripe.org/general-questions/show/21727#post318797)

Cheers
Wil