Ребят, помогите разобраться с затыком по этому уроку. Сделал, так сказать все по инструкции. Уже раз 5 проверил каждый файл посимвольно, идентично коду в примерах один в один. Но вот запара, после модификации файлов по этому уроку, при переходе по любому адресу выдается ошибка Internal server error 500. Вот исходники:
конец файла
bootstrap.php:
Код:
Route::set('admin', 'admin(/<controller>(/<action>(/<id>)))')
->defaults(array(
'directory' => 'admin',
'controller' => 'main',
'action' => 'index',
));
Route::set('comments', 'comments/<id>', array('id' => '.+'))
->defaults(array(
'controller' => 'comments',
'action' => 'index';
));
Route::set('articles', '<articles>(/<id>)', array('id' => '.+'))
->defaults(array(
'controller' => 'articles',
'action' => 'index'
));
if ( ! Route::cache())
{
Route::set('static', '<action>(/<id>)', array('action' => 'about|contacts'))
->defaults(array(
'controller' => 'static',
));
Route::cache(TRUE);
}
Route::set('default', '<controller>(/<action>(/<id>))')
->defaults(array(
'controller' => 'page',
'action' => 'index',
));
Контроллер
Articles.php:
Код:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Articles extends Controller_Common {
public function action_index()
{
$id = $this->request->param('id');
if($id)
{
$content = View::factory('/pages/article')
->set('article', $id)
->bind('comments', $comments);
$comments_url = 'comments/' . $id;
$comments = Request::factory($comments_url)->execute();
}
else
{
$content = View::factory('/pages/articles');
}
$this->template->content = $content;
}
} //END OF Articles
Контроллер
Comments.php:
Код:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Comments extends Controller {
public function action_index()
{
$id = $this->request->param('id');
$content = View::factory('/comments/show')
->bind('comments', $comments);
switch($id)
{
case 'article1':
$comments = array(
array('name' => 'Вася', 'comment' => 'Привет, Петя'),
array('name' => 'Петя', 'comment' => 'Привет, Вася!'),
);
break;
case 'article2':
$comments = array(
array('name' => 'Гена', 'comment' => 'Привет, Мир!'),
);
break;
default:
$comments = array();
break;
}
$this->response->body($content);
}
} //END OF Comments
Файл Вида
show.php:
Код:
<?php foreach($comments as $comment): ?>
<strong>Имя пользователя:</strong><br />
<?php echo $comment['name']; ?><br />
<strong>Комментарий пользователя:</strong><br />
<?php echo $comment['comment']; ?>
<br /><hr /><br />
<?php endforeach; ?>