How to use the Drupal Markup Engine module?
john.yi - March 18, 2008 - 10:00
How to use the Drupal Markup Engine module?
Help me and give me a simple example of using it.
Thanks a lot
How to use the Drupal Markup Engine module?
Help me and give me a simple example of using it.
Thanks a lot
Good question. I'm sorry, I
Good question. I'm sorry, I only just recently saw this thread.
The DME module is intended for a site developer who wants to create new tags for node content that does something - for instance, to place an image in a node. Once the tags are defined by a programmer, and the DME is added as a filter to the input format(s) that the site uses, then anyone who can use one of those input formats can enter a tag into the body and have it be processed.
The README.txt that comes with the dme module really gives the documentation on how to set up tags in code, and at this point you should probably go have a look. But let's say that you have a cck image type, which has an image field, and you want to refer to a given image node and display it's image in another node's body. Your example module might have code like this:
<?phpfunction example_dme_tags($op, $tag = '', $nid = 0, $params = array()) {
switch ($op) {
case 'list':
$tags = array();
$tags[] = array('tag' => 'image',
'allowed_attributes' => array('nid', 'align'),
'module' => 'example',
'type' => 'hook',
'name' => 'image',
'description' => 'Inserts an image.',
);
return $tags;
case 'call':
if ($tag == 'image') {
return get_image_tag($params['nid'], $params['align'], $params['dme_inner_text']);
}
}
}
?>
So, let's say we've got a tag set up with 'image', that wants an attribute of the node id, which is called 'nid', and another attribute that is called 'align' and takes a value of 'left', 'right', or 'center'. Then if you wanted the image of node 652 displaying on the left, you would put <dme:image nid="652" align="left" /> into the page where you would want the image to be.
It's possible you might even have it set up so that the dme:image tag contains the caption, where you would use <dme:image nid="652" align="left">This is the caption!</dme:image>. Above, the code $params['dme_inner_text'] would have the value "This is the caption!", the code $params['nid'] would have the value 652, and the code $params['align'] would have the value 'left'.
I also suggest looking at the dme_test_module example module that you get when you download the dme.
--
-john
DME usage
Hello John,
I know you're super busy but I thought I'd post this up here to see if you can help me out. In the example above, where would that code go? Should it be coded into a module of its own, and then enabled? I've tried this and it doesn't work for me.
Any pointers much appreciated.
Nick