Jump to:

1835 Posts in 1139 Topics by 554 members

Blog Module

SilverStripe Forums » Blog Module » Archive widget doesn't work

Discuss the Blog Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1 2 3
Go to End
Author Topic: 4419 Views
  • adesweb
    Avatar
    Community Member
    39 Posts

    Archive widget doesn't work Link to this post

    Upon installing the latest version of the blog module, I get the following error when trying to access an archive page (by year in this instance):

    Action '2009' isn't allowed on class BlogHolder_Controller

    Any ideas?

    I am running the latest stable version of SS.

    Adrian

  • MarijnKampf
    Avatar
    Community Member
    161 Posts

    Re: Archive widget doesn't work Link to this post

    I'm experiencing the same error. I've opened an bug ticket.

  • Bruce B
    Avatar
    Community Member
    145 Posts

    Re: Archive widget doesn't work Link to this post

    I have a temporary workaround, that may point to a solution for those with more knowledge.

    After line 176 in blog/BlogHolder.php, add the following to the '$allowed_actions' array:

    '2009',
    '2008',

    Then 2008 and 2009 become allowed actions and the archive works again.

    I've also updated the ticket with this text.

  • MarijnKampf
    Avatar
    Community Member
    161 Posts

    Re: Archive widget doesn't work Link to this post

    Thanks for finding and posting the work around bruceb!

    For people not too experienced with Silverstripe the file to patch is blog/code/BlogHolder.php and make sure to patch the BlogHolder_Controller class and not BlogHolder.

  • jdj
    Avatar
    Community Member
    3 Posts

    Re: Archive widget doesn't work Link to this post

    I just commented out the $allowed_actions array altogether. Probably not the best workaround, but it prevented me from having to enter all the existing and future dates.

  • Bruce B
    Avatar
    Community Member
    145 Posts

    Re: Archive widget doesn't work Link to this post

    Commenting out the allowed actions is probably not a good idea. The reason for this update is to patch a security hole and removing the $allowed_actions array presumably reopens it, at least partially.

    I wouldn't worry about allowing for future dates. If its a new site just enter '2009'. We can be almost certain that a new version of the blog module will be released before the end of 2009.

  • lestatron
    Avatar
    Community Member
    7 Posts

    Re: Archive widget doesn't work Link to this post

    I have found a better work around for this problem.


    bruceb: 28 September 2009 at 11:13am : "I should mention that I've added 'SearchForm' to the list of allowed actions in blogholder.php as well - otherwise search doesn't work within the blog."

    Action added to the allowed actions list.

    1) BlogHolder.php (Line 170)
    $allowed_actions add 'archive'

    ...
    static $allowed_actions = array(
          'postblog' => 'BLOGMANAGEMENT',
          'post' => 'BLOGMANAGEMENT',
          'BlogEntryForm' => 'BLOGMANAGEMENT',
          'rss',
          'tag',
          'archive',
          'showarchive',
    'SearchForm',
       );
    ...

    2) BlogHolder.php function BlogEntries() (Line 199)

    ...
    else if (Director::urlParam('Action') == 'archive')
             {
                $year = Director::urlParam('ID');
                $month = Director::urlParam('OtherID');

    ...

    3) ArchiveWidget.php (Lines 77 & 80 ) function Dates()

    ...
    if($this->DisplayMode == 'month') {
       $link = $blogHolder->Link() . 'archive/' . $sqlResult['Year']. '/' . sprintf("%'02d", $sqlResult['Month']);
    } else {
       $link = $blogHolder->Link() . 'archive/' . $sqlResult['Year'];
    }
    ...

  • Ultimate
    Avatar
    Community Member
    18 Posts

    Re: Archive widget doesn't work Link to this post

    Hey lestatron,

    I did all your suggested changes, but they don't work for me. The action seems to be allowed now, but the archive just shows all blog-entries, instead of only the entries of the specified month or year.

    4419 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.