Log in Sign Up

Magic Markers

A "marker" is used to indicate a place to insert a string or other information that is stored somewhere in the database. The simplest use is to simply pull the contents of a MagicEdit region and display it on the page. Note that a marker simply displays information, and does not associate any edit button with it; that is what the magicedit tag is for. But there are situations when you do not want the edit button, and markers give you an easy way to display content that can't be edited at that particular location (similar to using the me_hidebuttons option).

Markers are ClearLake functionality, so they are prefaced with a cl_ instead of the me_ prefix that you already know and love.

Here's a simple example of using a marker to display the contents of a particular MagicEdit region:

  <magicedit me_name="simon">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
  <p>"Simon" says:</p>
  <cl_marker cl_binding="$simon" />.

A couple of things to notice here. First, the syntax for a marker is <cl_marker cl_binding="something" />. If you wish to bind to a MagicEdit region, use a $ then the name of the region as shown in the example.

IMPORTANT NOTE: Because the database is not populated with data until the first edit of a region, you cannot use the $ binding method to bind to placeholder text. Use the ID method described below if you want to do that.

Markers with .created and .modified

You can use markers to display metadata about a MagicEdit region, such as when the content was created (the user first edited it) or changed. As an example, suppose you have a named MagicEdit region somewhere in your site, and you want to get the last time that particular region was edited. You can use cl_marker and bind it to your MagicEdit region like this:

  <magicedit me_name="monkey">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    "Monkey" was modified on <cl_marker cl_binding="$monkey.modified" />.

cl_marker will then be replaced by a date representing the last time monkey was modified. You would end up with something like this written to the page:

"Monkey" was modified on 2010-12-20 16:20:20.

Two methods are available to you: .modified and .created. Both utilize standard UNIX time, so in order to format your date you need to use cl_format along with a format string. You can use this manual as a reference for what conversion specification to use. Here's an example:

    Created on <cl_marker cl_binding="$monkey.modified" cl_format="%D at %r"/>.

This gives you a nicely formatted date and time that is a bit easier to read:

Created on 10/09/10 at 04:11:49 PM.

You could just as easily grab the day of the week, a 24 hour time (or no time at all), or whatever format you can come up with.

The ID Method

Occasionally you might want to bind a marker to some completely arbitrary thing on the page. Say you want to use a server side include in the head of the page but there is something that changes on every page (the title comes to mind, but there certainly other uses). You can bind to any element on the page (MagicEdit region or no) with a marker just like this:

  <div id="tagline">
    Feel the power of MagicEdit!
    Don't forget our motto: <cl_marker cl_binding="#tagline.value" />

Note that you need to use both the # syntax (just like selecting an element by ID in CSS) and the .value method. ClearLake will simply inject whatever the contents of the element with ID "tagline" are into the marker, including all HTML tags. The ID method can also be used to bind to a MagicEdit region's placeholder text if you don't expect it to be updated.

Try MagicEdit today!

Sign Up for free Demo
Scroll to Top