What's “the Drupal way” to do this (dynamic co

2019-08-13 22:30发布

问题:

This is a follow up question of How to get URL argument in Page body by PHP? .

Objective: Site content editor needs to show dynamic content, based on a URL parameter, i.e.:

URL:

http://example.com/node/1?Name=John

In Page node:

<?php if (isset($_GET['Name'])) { ?>

  <?php print "Dear " . $_GET['Name'] . ","; ?>

<?php } else { ?>

  Hello,

<?php } ?>

   blah blah blah ...

You may imagine the URL is from a link inside an EDM message. Both the EDM message and the Page content is maintained by the same content editor.

So, what is the Drupal way to archive this?

回答1:

You could create a module that extends the functionality of the token module to allow for the use of the various _GET variables as tokens in the body. The code to make the tokens available isn't a big deal, and using the token filter module below would make it simple for the editor to use the values in the node body.

http://drupal.org/project/token_filter



标签: drupal