Jump to content


Photo
- - - - -

Contoller Patterns


  • Please log in to reply
No replies to this topic

#1 Cris D.

Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,106 posts

Posted 16 July 2008 - 07:21 PM

I have spent considerable time trying various methods for creating controllers that make use of $etomite->runSnippet() to do a variety of things. This is one example of a method for creating a MVC (model, view, controller) using etomite technology.

$action=is_numeric($_POST['action']) ? $_POST['action']:'not numeric';
	 switch ($action)
	 {
		 case '1':
			   $output = "View for action 1- view from a chunk"; 
			   $snippetName = "MVC_action1_data";
			   $params = array('var1'=>$var1);
			   $view = $etomite->getChunk('MVC_action1_view');	   
		 break;
		 
		 case '2':
			   $output = "View for action 2- content from a spaghetti-code snippet (or use embedded PHP in a chunk with getChunk() )";
			   $snippetName = "MVC_action2_data";
			   $params = array('var1'=>$var1);
			   $view = $etomite->runSnippet('MVC_action2_view');
			
		 break;
		 
		 default:
			   $output = "default output- embedded data and view";
			   $data = $etomite->getIntTableRows("*", 
										'default_table', 
										$where ="",
										$sort="", $dir="ASC", 
										$limit="", $push=true, 
										$addPrefix=true
										);
			   $view = '<a href="{RandomLink}">{Random_Content}</a>';
		 break;
	 
	 
	 }
	 
	 if(!$data) $data = $etomite->runSnippet($snippetName,$params);
	 
	 $output .= $etomite->mergeCodeVariables($view, 
									$data,
									$prefix="{",$suffix="}",
									$oddStyle="",$evenStyle="",
									$tag="div"
									);
	 
	 return $output;
There are many other patterns, if anyone else has patterns they have found useful or other methods of creating controllers, I (and I'll bet others) woould love to have a peek...

Edited by Cris D., 16 July 2008 - 07:28 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users