0

I created a helper for my cakephp project. The helper creates a custom input field with a lot of complicated Javascript running at the backend of the input field. I get an error when I try to run my project though.

Code in my DropDownHelper.php file:

class DropDownHelper extends AppHelper {
?>
<!-- JQUERY LOADING -->
<script type="text/javascript"     src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.8/jquery-ui.min.js"></script>
<script>
  jQuery.curCSS = jQuery.css;
</script>
<!-- JQUERY LOADING -->

<!-- STYLE SHEET -->
<style>
  Some custom styles.
</style>
<!-- STYLE SHEET -->

<!-- SCRIPT -->
<script >
  My main Script.
</script>
<!-- SCRIPT -->

<!-- HTML -->
  Some HTML
<!-- HTML -->
<?php
}
?>

Part of my Controller:

class PortfoliosController extends AppController {
public $components = array('RequestHandler');
public $helpers  = array('DropDown');

And finally, my View:

echo $this->DropDown->input('Clients');

The error says: Parse error: syntax error, unexpected ';', expecting T_FUNCTION in /...../app/View/Helper/DropDownHelper.php on line 34

Lime 34 is Where I close off the php, right before my scripts, css, and html. i.e.

class DropDownHelper extends AppHelper {
?>

Line 34 is the line that says "?>".

Thanks!

1 Answer 1

1

So I figured this out myself. All that has to happen is this:

class DropDownHelper extends AppHelper {
public function functionName()
  {
    All the scripts, css, html
  }
}

So basically you have to put everything inside a function.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.