Created
August 7, 2012 14:38
-
-
Save SeanJA/3285895 to your computer and use it in GitHub Desktop.
I heard you like switches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_module_nodeapi(&$node, $op, $teaser, $page){ | |
$func = 'my_module_nodeapi_'.$node->type.'_'.$op; | |
if(function_exists($func)){ | |
$func(&$node, $teaser, $page); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_module_nodeapi(&$node, $op, $teaser, $page) { | |
switch ($op) { | |
case 'view': | |
switch ($node->type) { | |
case 'my_node_type': | |
//do the things | |
break; | |
case 'my_second_node_type': | |
//do the things | |
break; | |
} | |
break; | |
case 'load': | |
switch ($node->type) { | |
case 'my_node_type': | |
//do the things | |
break; | |
case 'my_second_node_type': | |
//do the things | |
break; | |
} | |
break; | |
case 'insert': | |
switch ($node->type) { | |
case 'my_node_type': | |
//do the things | |
break; | |
case 'my_second_node_type': | |
//do the things | |
break; | |
} | |
break; | |
case 'update': | |
switch ($node->type) { | |
case 'my_node_type': | |
//do the things | |
break; | |
case 'my_second_node_type': | |
//do the things | |
break; | |
} | |
break; | |
case 'delete': | |
switch ($node->type) { | |
case 'my_node_type': | |
//do the things | |
break; | |
case 'my_second_node_type': | |
//do the things | |
break; | |
} | |
break; | |
case 'load': | |
switch ($node->type) { | |
case 'my_node_type': | |
//do the things | |
break; | |
case 'my_second_node_type': | |
//do the things | |
break; | |
} | |
break; | |
case 'presave': | |
switch ($node->type) { | |
case 'my_node_type': | |
//do the things | |
break; | |
case 'my_second_node_type': | |
//do the things | |
break; | |
} | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment