1500 Posts in 413 Topics by 448 members
Blog Module
SilverStripe Forums » Blog Module » Blog management with Modeladmin
Discuss the Blog Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba
|
Page:
1
|
Go to End | |
| Author | Topic: | 1719 Views |
-
Blog management with Modeladmin

18 February 2010 at 4:50pm
Hi I have a question about implementing the model admin with the blog entries. so what I have done is the following
NewsAdmin.php
class NewsAdmin extends ModelAdmin {
public static $managed_models = array(
'BlogEntry'
);static $url_segment = 'news';
static $menu_title = 'News';
}thats its so far. I can work with the news i can search them but when i want to save i have some issues. i click in create new blog entrie and fill out everything. Then i click on add it add a new page to the site tree. Draft ! How can I add it to the blog holder, and publish it. If i edit the new again i have a publish button on the bottom but when i click on it nothing happends at all
. can someone help me with that ? -
Re: Blog management with Modeladmin

18 February 2010 at 6:35pm Last edited: 18 February 2010 6:36pm
i had a chat in the silverstripe icq chat and stuckinrealtime (as usual
) had something to fix the issue partly.
put the following code in BlogEntry.php (Model) if u have just one blogholder ! this will get the blogholder id and sets the PatentID to save the blogentries under these nodes.
public function onBeforeWrite() {
if(!$this->extension_instances['Versioned']->migratingVersion) {
if (!$this->ParentID) {
$tmp = DataObject::get_one('BlogHolder');
if ( (($tmp) && ($tmp instanceof BlogHolder)) && (!$this->ParentID)) {
$this->ParentID = $tmp->ID;
}
unset($tmp);
}
}
parent::onBeforeWrite();
}now there is just one issue how to publish a blog post from the model admin.
i will have a look and keep u posted -
Re: Blog management with Modeladmin

19 March 2010 at 2:29pm
Hi teejay,
You can try this (I haven't tested though).
function onAfterWrite(){
parent::onAfterWrite();
$this->publish("stage","Live");
}hope it helps.
cheers
Carlos -
Re: Blog management with Modeladmin

16 April 2010 at 12:39am
Hi teejay
did you end up getting this working? (blog post management via modeladmin rather than site-tree)
cheers
-
Re: Blog management with Modeladmin

3 October 2010 at 9:48am
I have come up with a workaround as it was troublesome to get Save & Publish actions working in Model Admin. I bet with more time I could probably come up with the proper actions in EditForm() on my extension of ModelAdmin controller.... but the workaround is simple. It works by reloading the CMS to the SiteTree object (e.g. admin/show/[recordID]).
Below is the code. When time avails I'd like to submit a patch to the core ModelAdmin_Recordcontroller that will detect if the currentRecord->is_a('SiteTree') and behave accordingly. Is there any interest in this?
My problem with doing everything from SiteTree is that the interface gets troublesome (e.g. the create button often shows the wrong classes, clicking go creates multiple records, etc. etc.) -- which I presume will be cleaned up in the JS rewrite of 3.0.
Here is:
<?php
class NewsAdmin extends ModelAdmin {
public static $managed_models = array(
'NewsPost'
);
public static $record_controller_class = "NewsAdmin_RecordController";static $url_segment = 'newsposts';
static $menu_title = 'News Posts';
}class NewsAdmin_RecordController extends ModelAdmin_RecordController {
private function href(){
// TODO: properly detect CMS URL, do not assume "[base]/admin"
return Director::baseURL() . 'admin/show/' . $this->currentRecord->ID;
}
private function redirectHTML(){
return '<script type="text/javascript">window.location = "' . $this->href() . '";</script>' .
'Redirecting... please wait. <a href="' . $this->href() . '">Click here</a> to continue...';
}
function EditForm(){
return new Form(
$this,
"EditForm",
new FieldSet(
new LiteralField('redirect', $this->redirectHTML())
),
new FieldSet()
);
}
function edit($request) {
if ($this->currentRecord) {
$href = Director::baseURL() . 'admin/show/' . $this->currentRecord->ID;
return new SS_HTTPResponse(
$this->redirectHTML(),
200,
sprintf("Redirecting to '%s' for editing.",$this->currentRecord->Title)
);
} else {
return _t('ModelAdmin.ITEMNOTFOUND', "I can't find that item");
}
}function view($request) {
if($this->currentRecord) {
$href = $this->href();
return new SS_HTTPResponse(
$this->redirectHTML(),
200,
sprintf("Redirecting to '%s' for viewing.",$this->currentRecord->Title)
);
} else {
return _t('ModelAdmin.ITEMNOTFOUND', "I can't find that item");
}
}
} -
Re: Blog management with Modeladmin

4 December 2010 at 1:50pm
I don't know about anyone else, but i would love it if a model admin for Blog was part of the core blog module (maybe some you could enable/disable in your _config).
I hear a lot of grumbles from clients who have used wordpress about how they prefer Wordpress' interface for blogging. I think maybe giving a 'posts' page, built on top of model admin might be a nice middle ground.
brice: I agree about your comment on SiteTree's interface. Blogging is meant to be simple, click and post. I know you can use the /post action, but that does not seem to allow you to do things like attach images or use TinyMCE's full screen editor.
Also, when you expand all your blog posts it can result in SiteTree becoming massively long :s.
Mo
-
Re: Blog management with Modeladmin

22 December 2010 at 10:23am
Hi there,
We want to improved Blog Module (ModelAdmin like) for Silverstripe 3.0
cheers
Carlos
| 1719 Views | ||
|
Page:
1
|
Go to Top |



