Jump to main content Jump to doc navigation

The Inline PHP widget acts very similar to the Snippet Widget, except it runs the content of the widget as if it were a Snippet.

Usage

Simply place your PHP code in the content panel, and return the output of your widget.

For example, this will display "Hello, World!":

<?php
return 'Hello, World!';

A few notes about using this:

  • Do not "echo" content, as it will be ignored
  • Do not use $modx->resource in your widget, as there is no active resource for the dashboard
  • Do not put a closing PHP tag at the end of your code! For some reason, it gets parsed incorrectly (as of MODX 2.2.8)

See Also

  1. Dashboard Widget Type - File
  2. Dashboard Widget Type - HTML
  3. Dashboard Widget Type - Inline PHP
  4. Dashboard Widget Type - Snippet

Support the team building MODX with a monthly donation.

The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.

Backers

  • modmore
  • STERC
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • eydolan
  • Following Sea
  • Lefthandmedia
  • Murray Wood
  • Anton Tarasov
  • Stéphane Jäggi
  • Raffy
  • Snow Creative
  • A. Moreno
  • Nick Clark
  • JT Skaggs
  • Helen
  • YJ
  • krisznet
  • Richard
  • Yanni

Budget

$311 per month—let's make that $500!

Learn more