MODx Advanced FAQ

If you don't find an answer here, ask for help in the appropriate section of the MODX Forums. If they might have a bearing on your problem, be sure to include your browser version, MODX version, hosting service, Apache version, PHP version, and MySQL version.


Click on a question to expand the answer

Show All      Hide All

What's the difference between site_url and base_url when used in tags?

The site_url is a full URL (e.g. https://bobsguides.com). The base_url is missing the URL prefix (e.g. /bobsguides.com).

Your template should always include a base href statement using the site_url:

MODX Evolution: <base href="[(site_url)]" />
MODX Revolution: <base href="[[++site_url]]" />

What's the proper way to create a link to a page at my site?

Links in a MODX site should always be expressed with the link tag:

MODX Evolution [~##~]
MODX Revolution [[~##]]
(where ## is the document ID of the document being linked to. Examples:

MODX Evolution: <a href="[~12~]">Link to document 12</a>
MODX Revolution: <a href="[[~12]]">Link to document 12</a>

If you would like a fully qualified link for SEO purposes, you can use this form instead:

MODX Evolution: <a href="[(site_url)][~12~]">Link to document 12</a>
MODX Revolution: <a href = "[[++site_url]][[~12]]">Link to document 12</a>

I can't get Friendly URLs to work in XAMPP. What am I doing wrong?

XAMPP has mod_rewrite off by default. Uncomment the following line in xampp/apache/conf/httpd.conf:

LoadModule rewrite_module modules/mod_rewrite.so

How can I get the document ID of the current document in a plugin?

MODX Evolution: $docid = $e->params['id'];
MODX Revolution: $docid = $modx->resource->get('id');

What other params are available to plugins attached to system events?

It depends on the event. Susan Ottwell has a good list here. They are available as simple variables. Another list can be found here.

What causes this error? Fatal error: Allowed memory size of 33554432 bytes exhausted

This almost always means that you have a circular reference on your site. A page forwards users to another page that forwards users back to the first page, ad infinitum. The most common cause is having an unpublished or missing error or unauthorized page. User's who try to access a non-existent URL are forwarded to the error page. If the error page isn't published, it too doesn't exist and they're forwarded again to the same page over and over until the memory runs out. Check the error_page and unauthorized_page system settings and make sure the pages referred to there are published and not protected by a permission setting.

Another possibility is a snippet such as Ditto, that pulls content from a page that has the same Ditto tag on it (or in the template attached to it).

Finally, if your memory limit is 32M or less, Ditto and some other snippets can exhaust it in their normal operation. Try increasing the memory_limit setting in php.ini.

I have extra back-slashes showing up in my code. Where are they coming from?

You need to turn of magic_quotes_gpc. Look here.

How can I send $_GET arguments in a URL from a snippet in Revolution?

Create the URL with $modx->makeURL() like this:

$url = $modx->makeUrl($id, '', 'paramName=value');

How did you create this marvelous FAQ?

The FAQ uses some JavaScript code from DynamicDrive.com and is extremely easy to create and maintain in MODX thanks to the EZfaq Snippet, created by (ahem) me. Go here to see the EZfaq tutorial.

 

My book, MODX: The Official Guide - Digital Edition is now available here. The paper version of the book may still be available from Amazon.

If you have the book and would like to download the code, you can find it here.

If you have the book and would like to see the updates and corrections page, you can find it here.

MODX: The Official Guide is 772 pages long and goes far beyond this web site in explaining beginning and advanced MODX techniques. It includes detailed information on:

  • Installing MODX
  • How MODX Works
  • Working with MODX resources and Elements
  • Using Git with MODX
  • Using common MODX add-on components like SPForm, Login, getResources, and FormIt
  • MODX security Permissions
  • Customizing the MODX Manager
  • Using Form Customization
  • Creating Transport Packages
  • MODX and xPDO object methods
  • MODX System Events
  • Using PHP with MODX

Go here for more information about the book.

Thank you for visiting BobsGuides.com

  —  Bob Ray