advanced.php 865 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /**
  3. * This snippet demonstrates how to change the value of a hook. The content
  4. * passed into the hook is 'This is some Sample Content.'. After the two hook
  5. * handlers are done, the new content is 'This is some $@mple Content.'.
  6. */
  7. // the output:page hook is triggered by elgg_view_page().
  8. elgg_register_plugin_hook_handler('output', 'page', 'example_plugin_hook_handler', 600);
  9. elgg_register_plugin_hook_handler('output', 'page', 'example_plugin_hook_handler_2', 601);
  10. function example_plugin_hook_handler($hook, $type, $value, $params) {
  11. // change a to @
  12. $value = str_replace('a', '@', $value);
  13. return $value;
  14. }
  15. function example_plugin_hook_handler_2($hook, $type, $value, $params) {
  16. // change S to $
  17. $value = str_replace('S', '$', $value);
  18. return $value;
  19. }
  20. $content = 'This is some Sample Content.';
  21. echo elgg_view_page('Title', $content);