FIX Path to author profile when blog is the homepage

This commit is contained in:
Robbie Averill 2016-12-19 12:12:08 +13:00
parent f376b1c2f1
commit 83db670e14
5 changed files with 52 additions and 37 deletions

View File

@ -6,6 +6,7 @@ use Page;
use Page_Controller; use Page_Controller;
use SilverStripe\Blog\Admin\GridFieldCategorisationConfig; use SilverStripe\Blog\Admin\GridFieldCategorisationConfig;
use SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost; use SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost;
use SilverStripe\CMS\Controllers\RootURLController;
use SilverStripe\Control\Controller; use SilverStripe\Control\Controller;
use SilverStripe\Control\RSS\RSSFeed; use SilverStripe\Control\RSS\RSSFeed;
use SilverStripe\Core\Convert; use SilverStripe\Core\Convert;
@ -569,7 +570,13 @@ class Blog extends Page implements PermissionProvider
*/ */
public function ProfileLink($urlSegment) public function ProfileLink($urlSegment)
{ {
return Controller::join_links($this->Link(), 'profile', $urlSegment); $baseLink = $this->Link();
if ($baseLink === '/') {
// Handle homepage blogs
$baseLink = RootURLController::get_homepage_link();
}
return Controller::join_links($baseLink, 'profile', $urlSegment);
} }
/** /**

View File

@ -637,7 +637,7 @@ class BlogPost extends Page
*/ */
public function getCredits() public function getCredits()
{ {
$list = new ArrayList(); $list = ArrayList::create();
$list->merge($this->getDynamicCredits()); $list->merge($this->getDynamicCredits());
$list->merge($this->getStaticCredits()); $list->merge($this->getStaticCredits());

View File

@ -69,7 +69,7 @@ class Blog_Controller extends Page_Controller
/** /**
* Renders a Blog Member's profile. * Renders a Blog Member's profile.
* *
* @return SS_HTTPResponse * @return HTTPResponse
*/ */
public function profile() public function profile()
{ {

View File

@ -25,7 +25,15 @@
<% if $Credits %> <% if $Credits %>
<%t Blog.By "by" %> <%t Blog.By "by" %>
<% loop $Credits %><% if not $First && not $Last %>, <% end_if %><% if not $First && $Last %> <%t Blog.AND "and" %> <% end_if %><% if $URLSegment %><a href="$URL">$Name.XML</a><% else %>$Name.XML<% end_if %><% end_loop %>
<% end_if %>
<% loop $Credits %>
<% if not $First && not $Last %>, <% end_if %>
<% if not $First && $Last %> <%t Blog.AND "and" %> <% end_if %>
<% if $URLSegment %>
<a href="$URL">$Name.XML</a>
<% else %>
$Name.XML
<% end_if %>
<% end_loop %>
<% end_if %>
</p> </p>

View File

@ -1,6 +1,6 @@
<?php <?php
use SilverStripe\Blog\Controllers\BlogController; use SilverStripe\Blog\Model\Blog_Controller;
use SilverStripe\CMS\Controllers\ContentController; use SilverStripe\CMS\Controllers\ContentController;
use SilverStripe\Control\Controller; use SilverStripe\Control\Controller;
use SilverStripe\Control\Director; use SilverStripe\Control\Director;
@ -148,7 +148,7 @@ class BlogTest extends SapphireTest
public function testArchiveYear() public function testArchiveYear()
{ {
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog'); $blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
$controller = new BlogController($blog); $controller = new Blog_Controller($blog);
$this->requestURL($controller, 'first-post/archive/'); $this->requestURL($controller, 'first-post/archive/');
$this->assertEquals(2013, $controller->getArchiveYear(), 'getArchiveYear should return 2013'); $this->assertEquals(2013, $controller->getArchiveYear(), 'getArchiveYear should return 2013');
} }
@ -287,7 +287,7 @@ class BlogTest extends SapphireTest
public function testFilteredCategories() public function testFilteredCategories()
{ {
$blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog'); $blog = $this->objFromFixture('SilverStripe\\Blog\\Model\\Blog', 'FirstBlog');
$controller = new BlogController($blog); $controller = new Blog_Controller($blog);
// Root url // Root url
$this->requestURL($controller, 'first-post'); $this->requestURL($controller, 'first-post');