Mais conteúdo relacionado Semelhante a Word Camp Kansai 2014 - MVC Framework (20) Word Camp Kansai 2014 - MVC Framework10. M - Model
V - View
C - Controller
ex: Codeigniter, CakePhp, Rails, Django
21. What do we need?
Router ( ディスパッ
チ )
Custom post types class
Views
Libraries
23. Custom Post Type Class
http://github.com/
jjgrainger/
wp-custom-post-type-
class/
28. static function show_student_profile( $router ) {
$args = array(
'path' => '^profile/(.*?)$',
'query_vars' => array(
'user_id' => 1,
),
'page_callback' => array( 'Alyte_Students','get' ),
'page_arguments' => array('user_id'),
'access_callback' => true,
'title' => 'Your Student Profile',
'template' => array('page.php', dirname(__FILE__).DIRECTORY_SEPARATOR.'page.php')
);
$router->add_route( 'show-student-profile-route', $args );
}
MAGIC HAPPENS HERE
class-routes.php
29. Student Class
static function get($id)
{
$user = new User($id);
$data = array( 'id' =>$id, 'user' => $user, );
// Plates PHP
$template = self::make_template();
$template->data($data);
return $template->render('students/profile_view');
}