Blog route: Change 'id' to 'permlink'
This commit is contained in:
parent
e153924e10
commit
1f7aec1628
5 changed files with 10 additions and 8 deletions
|
|
@ -151,11 +151,11 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|||
'controller' => 'index',
|
||||
'action' => 'index',
|
||||
)));
|
||||
$router->addRoute('blog-default',new Zend_Controller_Router_Route(':lang/blog/:action/:id',array(
|
||||
$router->addRoute('blog-default',new Zend_Controller_Router_Route(':lang/blog/:action/:permlink',array(
|
||||
'module' => 'blog',
|
||||
'controller' => 'index',
|
||||
'action' => 'latest',
|
||||
'id' => ''
|
||||
'permlink' => ''
|
||||
),array(
|
||||
'action' => '(latest|read|readable)'
|
||||
)));
|
||||
|
|
|
|||
|
|
@ -23,11 +23,13 @@ class Blog_IndexController extends Fiktiv_Controller_Action
|
|||
{
|
||||
$posts = new ModelBlogPost();
|
||||
|
||||
$this->view->post = $posts->findByPermlink($this->_getParam('id', null));
|
||||
$plink = $this->_getParam('permlink');
|
||||
$post = $posts->findByPermlink($plink);
|
||||
|
||||
if (!$this->view->post)
|
||||
if (!$post) {
|
||||
$this->_redirect(array('action' => 'latest'));
|
||||
|
||||
}
|
||||
|
||||
$this->view->post = $post;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
<?php foreach($this->posts as $post) : ?>
|
||||
<div class="blogpost">
|
||||
<h3><a href="<?=$this->url(array('action' => 'read','id' => $post->permlink),'blog-default') ?>"><?=$post->title ?></a></h3>
|
||||
<h3><a href="<?=$this->url(array('action' => 'read', 'permlink' => $post->permlink),'blog-default') ?>"><?=$post->title ?></a></h3>
|
||||
<p class="publish"><?=$post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->firstName ?></p>
|
||||
<div class="content">
|
||||
<?= $hl->replaceCodeblock($post->content) ?>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
<?php foreach($this->posts as $post) : ?>
|
||||
<div class="blogpost">
|
||||
<h3><a href="<?=$this->url(array('action' => 'read','id' => $post->permlink),'blog-default') ?>"><?=$post->title ?></a></h3>
|
||||
<h3><a href="<?=$this->url(array('action' => 'read', 'permlink' => $post->permlink),'blog-default') ?>"><?=$post->title ?></a></h3>
|
||||
<p class="publish"><?=$post->getPubDate()->toString('yyyy-MM-dd').' '.$this->translate('TIME_AT').' '.$post->getPubDate()->toString('HH:mm').' '.$post->getAuthor()->firstName ?></p>
|
||||
<div class="content">
|
||||
<?= $hl->replaceCodeblock($post->content) ?>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
<?php if (isset($this->post)): ?>
|
||||
|
||||
<a href="<?=$this->url(array('action' => 'latest', 'id' => ''), 'blog-default') ?>">« <?=$this->translate('u:back') ?></a>
|
||||
<a href="<?=$this->url(array('action' => 'latest', 'permlink' => ''), 'blog-default') ?>">« <?=$this->translate('u:back') ?></a>
|
||||
|
||||
<div class="blogpost">
|
||||
<h1><?=$this->post->title ?></h1>
|
||||
|
|
|
|||
Reference in a new issue