Closed nzstephenf closed 8 years ago
Hi @nzstephenf
Would you mind sharing the code that you have in your config, and the CatalogPageAdmin extension you are using? :smile:
Which GridFieldButtons are you trying to add - an example of that would be good too.
I'll have a quick look at the searching!
Hey @stevie-mayhew Sure :smile: !
Name: mysite After:
SiteTree: extensions:
ArticlePage: extensions:
class ArticleAdmin extends CatalogPageAdmin {
private static $managed_models = array(
'ArticlePage' => array('title' => 'Latest Articles'),
'ArticleType' => array('title' => 'Article Types'),
'ArchiveHolder' => array('title' => 'Archive Holder'),
'ArticleHolder' => array('title' => 'Article Holder')
);
private static $menu_priority = 9;
private static $url_segment = 'articles';
private static $menu_title = 'Articles';
private static $menu_icon = 'mysite/icons/article.png';
public function init(){
parent::init();
Requirements::themedCSS("articleadmin");
Requirements::javascript("mysite/js/ArticleWorkflowField.js");
}
public function getEditForm($id = null, $fields = null){
if(!$id) $id = $this->currentPageID();
$form = parent::getEditForm($id, $fields);
$record = $this->getRecord($id);
if($record && !$record->canView()){
return Security::permissionFailure($this);
}
$gridField = $form->Fields()->fieldByName($this->sanitiseClassName($this->modelClass));
$gridField->getConfig()->addComponent(new GridFieldFilterHeader());
if($this->modelClass == 'ArticlePage') {
/**
* the lines below is custom GridField Action Buttons but when clicked now
* it just comes up with an error that it couldn't fetch data. But it
* worked normally
*/
$gridField->getConfig()->addComponent(new GridFieldSWRAction());
$gridField->getConfig()->addComponent(new GridFieldArticleDeleteAction());
$gridField->getConfig()->addComponent(new GridFieldArticlePublishAction());
$gridField->getConfig()->removeComponentsByType('GridFieldDeleteAction');
}
return $form;
}
}
public function handleAction(GridField $gridField, $actionName, $arguments, $data) {
if($actionName == 'swr') {
$item = ArticlePage::Get()->byId($arguments['RecordID']);
$item->SWR = 1;
$item->writeToStage('Stage');
$item->publish('Stage', 'Live');
}
}
Is there a more cleaner and efficient way of adding these buttons possibly?
Here is what's in the ArticlePage:
class ArticlePage extends Page {
private static $searchable_fields = array(
"Title",
"URLSegment",
"Created"
);
private static $summary_fields = array(
"Title" => "Title",
"Created" => "Article Date",
"ArticleType.Title" => "Type",
"Author" => "Author",
"Parent.Title" => "Sub Category",
"SWR" => "S*** Worth Reading"
);
And ArticleHolder is basically the same as above.
Hey @nzstephenf - that all looks pretty standard stuff, I'll set up a test for this later tonight and see if I can replicate it but I'm not sure at this stage whats going wrong.
You're on master or the latest version of the module?
@stevie-mayhew I'm on the master version of the module and used Composer to install :)
Hey @nzstephenf is this still an issue for you? Sorry on the slow reply!
Hey @stevie-mayhew, didn't realise I got a reply til now. It's actually working nice and smoothly. Cheers for the module by the way. It works a charm!
Awesome, let us know if you have any other issues :)
Hey guys, Really diggin' this addon.
I've got two things - how do I go about adding GridFieldButtons to my CatalogModelAdmin? My existing buttons that were working before installing the module no longer works.
The other thing - the filter search within the CatalogModelAdmin has been quite buggy and some things don't show up in search.
But the main thing I want to bring up is that some article pages which are controlled within a CatalogModelAdmin cannot be seen in the list, so I tried to access the edit page of an article page manually at "/admin/articleadmin/ArticlePage/EditForm/field/ArticlePage/item/12345/edit". I get a white page of death but with the power of display_errors. I found this error to appear:
"Fatal error: Call to a member function isPublished() on a non-object in /silverstripe-catalogmanager/code/Forms/CatalogPageGridFieldDetailForm.php on line 29".