Jump to content

Help correcting a error


dzhax

Recommended Posts

I am working on a widget for Social Engine 4 and Randomly get the following error

Parse error: syntax error, unexpected '}' in /home/standth1/public_html/csr/application/widgets/fightsubmit/Controller.php(8) : runtime-created function on line 1Fatal error: Function name must be a string in /home/standth1/public_html/csr/application/widgets/fightsubmit/Controller.php on line 10

I was trying to change the variable "data" into something more descriptive when it started. So I did what I normally do... I put it all back to data. And I am still getting the same exact message.Controller.php:

<?phpclass Widget_FightSubmitController extends Engine_Content_Widget_Abstract{   public function indexAction()  {  $scode = $this->_getParam('data');  $func = create_function (null, $scode );  ob_start();  $func();  $this->view->data = ob_get_contents();  ob_end_clean();  }}?>

Manifest.php:

<?phpreturn array(  'package' => array(	'type' => 'widget',	'name' => 'fightsubmit',	'version' => '1.0.0',	'path' => 'application/widgets/fightsubmit',	'repository' => '',	'meta' => array(	  'title' => 'Fight Submit',	  'description' => 'Submit fight data.',	  'author' => 'garrett-innovations.com',	),	'directories' => array(	  'application/widgets/fightsubmit',	),  ),  // Backwards compatibility  'type' => 'widget',  'name' => 'fightsubmit',  'version' => '1.0.0',  'title' => 'Fight Submit',  'description' => 'Submit fight data.',  'category' => 'Widgets',   'autoEdit' => true,	'adminForm' => array(	  'elements' => array(		array(		  'Text',		  'data',		  array(			'label' => 'Minimum CP Access Level:'		  )		),	  )	),) ?>

index.tpl:

<?php	 $currentDisplayName = Engine_Api::_()->user()->getViewer()->displayname;	 echo 'Welcome, ' . $currentDisplayName;	 $currentAuthLevel = Engine_Api::_()->user()->getViewer()->level_id;	 echo '<br/>Authorization Level: ' . $currentAuthLevel . '<br/><br/>';	 echo 'Minimum Auth Level: '. $this->data . '<br/><br/>';?>

Any help on this is much appreciated.

Link to comment
Share on other sites

$scode echos 3which is correct 3 should display on the index.tpl for the minimum auth level.is it maybe because its a number and not letters? I'm not sure exactly what is going on it is a take existing code and modify it to suite my needs type of thing.

Link to comment
Share on other sites

If $scode is "3" then running create function tells it to do this:

function temp(null){  3}

Obviously, that's not valid PHP syntax, which is why you get the parse error. At a minimum the 3 should have a semicolon after it, but even so that's not going to create a useful function. This doesn't do anything:

function temp(null){  3;}

Link to comment
Share on other sites

ok its working now i ripped out all the ob connection garbage and just set $this->view->data = $scode;It loads fine now. Not sure what the ob connection thing does but it must need a specific syntax to work properly.Ingolme thanks for the idea of echoing $scode. at first i would navigate directly to controller.php and get 3 but when i naviagted to the index the 3 still showed on the page thats when I made the above changes.

<?phpclass Widget_FightSubmitController extends Engine_Content_Widget_Abstract{   public function indexAction()  {  $scode = $this->_getParam('data');  $this->view->data = $scode;  }}?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...