Skip to content

Commit

Permalink
Merge pull request #27 from wedevelopnl/fix/single-article-block
Browse files Browse the repository at this point in the history
Fix/single article block
  • Loading branch information
Dennisprins93 authored Jun 12, 2023
2 parents ea2ba2f + 61270a2 commit 959dbb0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
2 changes: 2 additions & 0 deletions lang/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ nl:
SHOWMOREBUTTON: 'Toon meer artikelen button'
SHOWMOREBUTTONTEXT: 'Meer artikelen buttontekst'
NOARTICLESFOUND: 'Geen artikelen gevonden'
ARTICLESPAGE: 'Artikelen overzicht pagina'
WeDevelop\Articles\ElementalGrid\ElementArticle:
ARTICLESPAGE: 'Artikelen overzicht pagina'
ARTICLETOSHOW: 'Artikel om weer te geven'
NOARTICLEFOUND: 'Geen artikel gevonden'

32 changes: 19 additions & 13 deletions src/ElementalGrid/ElementArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
namespace WeDevelop\Articles\ElementalGrid;

use DNADesign\Elemental\Models\BaseElement;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\TreeDropdownField;
use UncleCheese\DisplayLogic\Forms\Wrapper;
use WeDevelop\Articles\Pages\ArticlePage;
use WeDevelop\Articles\Pages\ArticlesPage;

Expand All @@ -15,6 +17,7 @@
* @package WeDevelop\Articles\ElementalGrid
*
* @method ArticlePage ArticlePage()
* @method ArticlesPage ArticlesPage()
*/
class ElementArticle extends BaseElement
{
Expand Down Expand Up @@ -63,33 +66,36 @@ public function getCMSFields(): FieldList
{
$fields = parent::getCMSFields();

$fields->addFieldsToTab(
'Root.Main',
[
TreeDropdownField::create('ArticlePageID', _t(__CLASS__ . '.ARTICLETOSHOW', 'Article to show'), ArticlePage::class),
]
);

$fields->removeByName(
[
'ShowMoreArticlesButton',
'ArticlesPageID',
'ArticlePageID',
'ShowMoreArticlesButtonText',
]
);

$fields->addFieldsToTab(
'Root.Main',
[
TreeDropdownField::create(
'ArticlePageID',
_t(__CLASS__ . '.ARTICLETOSHOW', 'Article to show'),
ArticlePage::class),
CheckboxField::create(
'ShowMoreArticlesButton',
_t('WeDevelop\Articles\ElementalGrid.SHOWMOREBUTTON', "Show 'more articles' button")
),
TreeDropdownField::create('ArticlesPageID', 'Articles page', ArticlesPage::class),
TextField::create(
'ShowMoreArticlesButtonText',
_t('WeDevelop\Articles\ElementalGrid.SHOWMOREBUTTONTEXT', "Show 'more articles' button text")
)
Wrapper::create([
TreeDropdownField::create(
'ArticlesPageID',
_t(__CLASS__ . '.ARTICLESPAGE', 'Articles overview page'),
SiteTree::class),
TextField::create(
'ShowMoreArticlesButtonText',
_t('WeDevelop\Articles\ElementalGrid.SHOWMOREBUTTONTEXT', "Show 'more articles' button text")
),
])
->displayIf('ShowMoreArticlesButton')
->isChecked()
->end(),
Expand All @@ -103,6 +109,6 @@ public function getCMSFields(): FieldList

public function getType(): string
{
return 'Article';
return 'Single article';
}
}
24 changes: 12 additions & 12 deletions src/ElementalGrid/ElementArticles.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SilverStripe\ORM\DataList;
use SilverStripe\ORM\ManyManyList;
use SilverStripe\TagField\TagField;
use UncleCheese\DisplayLogic\Forms\Wrapper;
use WeDevelop\Articles\Models\Author;
use WeDevelop\Articles\Pages\ArticlePage;
use WeDevelop\Articles\Pages\ArticlesPage;
Expand Down Expand Up @@ -53,7 +54,7 @@ class ElementArticles extends BaseElement
/**
* @var string
*/
private static $icon = 'font-icon-p-list';
private static $icon = 'font-icon-menu-campaigns';

/**
* @var array
Expand Down Expand Up @@ -91,12 +92,9 @@ public function getCMSFields(): FieldList
{
$fields = parent::getCMSFields();

$fields->addFieldsToTab(
'Root.Main',
[
TreeDropdownField::create('ArticlesPageID', 'Articles page', SiteTree::class),
]
);
$fields->addFieldsToTab('Root.Main', [
TreeDropdownField::create('ArticlesPageID', _t(__CLASS__ . '.ARTICLESPAGE', 'Articles overview page'), SiteTree::class),
]);

$fields->removeByName(
[
Expand Down Expand Up @@ -151,10 +149,12 @@ public function getCMSFields(): FieldList
'ShowMoreArticlesButton',
_t(__CLASS__ . '.SHOWMOREBUTTON', "Show 'more articles' button")
),
TextField::create(
'ShowMoreArticlesButtonText',
_t(__CLASS__ . '.SHOWMOREBUTTONTEXT', "Show 'more articles' button text")
)
Wrapper::create([
TextField::create(
'ShowMoreArticlesButtonText',
_t(__CLASS__ . '.SHOWMOREBUTTONTEXT', "Show 'more articles' button text")
),
])
->displayIf('ShowMoreArticlesButton')
->isChecked()
->end(),
Expand All @@ -169,7 +169,7 @@ public function getCMSFields(): FieldList

public function getType(): string
{
return 'Articles list';
return 'Articles overview';
}

public function getArticles(): ?DataList
Expand Down

0 comments on commit 959dbb0

Please sign in to comment.