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 SilverStripe\Blog\Admin\GridFieldCategorisationConfig;
use SilverStripe\Blog\Forms\GridField\GridFieldConfig_BlogPost;
use SilverStripe\CMS\Controllers\RootURLController;
use SilverStripe\Control\Controller;
use SilverStripe\Control\RSS\RSSFeed;
use SilverStripe\Core\Convert;
@ -569,7 +570,13 @@ class Blog extends Page implements PermissionProvider
*/
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()
{
$list = new ArrayList();
$list = ArrayList::create();
$list->merge($this->getDynamicCredits());
$list->merge($this->getStaticCredits());

View File

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

View File

@ -1,31 +1,39 @@
<p class="blog-post-meta">
<% if $Categories.exists %>
<%t Blog.PostedIn "Posted in" %>
<% loop $Categories %>
<a href="$Link" title="$Title">$Title</a><% if not Last %>, <% else %>;<% end_if %>
<% end_loop %>
<% end_if %>
<% if $Categories.exists %>
<%t Blog.PostedIn "Posted in" %>
<% loop $Categories %>
<a href="$Link" title="$Title">$Title</a><% if not Last %>, <% else %>;<% end_if %>
<% end_loop %>
<% end_if %>
<% if $Tags.exists %>
<%t Blog.Tagged "Tagged" %>
<% loop $Tags %>
<a href="$Link" title="$Title">$Title</a><% if not Last %>, <% else %>;<% end_if %>
<% end_loop %>
<% end_if %>
<% if $Tags.exists %>
<%t Blog.Tagged "Tagged" %>
<% loop $Tags %>
<a href="$Link" title="$Title">$Title</a><% if not Last %>, <% else %>;<% end_if %>
<% end_loop %>
<% end_if %>
<% if $Comments.exists %>
<a href="{$Link}#comments-holder">
<%t Blog.Comments "Comments" %>
$Comments.count
</a>;
<% end_if %>
<% if $Comments.exists %>
<a href="{$Link}#comments-holder">
<%t Blog.Comments "Comments" %>
$Comments.count
</a>;
<% end_if %>
<%t Blog.Posted "Posted" %>
<a href="$MonthlyArchiveLink">$PublishDate.ago</a>
<%t Blog.Posted "Posted" %>
<a href="$MonthlyArchiveLink">$PublishDate.ago</a>
<% if $Credits %>
<%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 %>
<% if $Credits %>
<%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 %>
</p>

View File

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