Login

Recover Your Password

Return to Product Support > Learning Center > Developer References > Creating Add-ons > Using Inline Scripts

Using Inline Scripts

Inline Scripts is a method of adding script programs in languages like php to add-ons. Inline scripts can be placed anywhere on the page, but are executed after the page is rendered by Contensive and returned to the webserver's scriting environment.

Simple Rules

  • Do not start and end with the script with the script's escape sequence,  like <$PHP.
  • Use the return command to place a string where the add-on was placed.
  • You can use a function(), but it is not needed. If you include your code in a function, end the script with: return myFunction()
  • You can use any of the script language's context objects and functions, as well as the Contensive cp object.

Example

  1. Create a new addon
  2. Give it a name
  3. In the placement tab, check In Content
  4. In the Inline Script tab, add this: return $cp->user->name
  5. edit a page and place the addon on the page
  6. View the page and the add-on shows thier name