diff --git a/books/dev.yml b/books/dev.yml index 2e0cdab079f9f8a48eebdd7cdabcc435a5c89f56..6dfade769c3655f35b751b5c958c1ac39ff5235d 100644 --- a/books/dev.yml +++ b/books/dev.yml @@ -1,6 +1,7 @@ name: Developer guide weight: 10 description: For CiviCRM developers +category: Core langs: en: repo: 'https://github.com/civicrm/civicrm-dev-docs' diff --git a/books/user.yml b/books/user.yml index b9a237375b13667d1cb1c829b00b492fdb9f6201..fe833f985a085e5186bb8ee0ba75b8793794b86b 100644 --- a/books/user.yml +++ b/books/user.yml @@ -1,6 +1,7 @@ name: User guide weight: -100 description: Aimed at day to day users of CiviCRM. +category: Core langs: en: repo: 'https://github.com/civicrm/civicrm-user-guide' diff --git a/src/AppBundle/Controller/ReadController.php b/src/AppBundle/Controller/ReadController.php index c76be285873e1a13c38d8d32e8a8ccc6fffb87b1..ddedd20c06956332e6d7204e95382b954b956c36 100644 --- a/src/AppBundle/Controller/ReadController.php +++ b/src/AppBundle/Controller/ReadController.php @@ -11,9 +11,14 @@ class ReadController extends Controller { * @Route("/") */ public function HomeAction() { + /** @var \AppBundle\Model\Library $library */ + $library = $this->get('library'); + return $this->render( - 'AppBundle:Read:home.html.twig', - array('library' => $this->get('library')) + 'AppBundle:Read:home.html.twig', array( + 'core_books' => $library->getBooksByCategory('Core'), + 'extensions_books' => $library->getBooksByCategory('Extensions'), + ) ); } diff --git a/src/AppBundle/Model/Book.php b/src/AppBundle/Model/Book.php index 3a9aa692de090e4ee46480aa3ea4695e10cd5fb9..128dfdd98cb07e1fd24c3cab82cba9ed061a9c17 100644 --- a/src/AppBundle/Model/Book.php +++ b/src/AppBundle/Model/Book.php @@ -33,6 +33,12 @@ class Book { */ public $weight; + /** + * + * @var string (e.g. "Core", "Extensions") Should be in sentence case + */ + public $category; + /** * Creates a book based on a yaml conf file * @@ -49,6 +55,8 @@ class Book { foreach ($yaml['langs'] as $code => $languageData) { $this->languages[] = new Language($code, $languageData); } + $category = isset($yaml['category']) ? $yaml['category'] : "Extensions"; + $this->category = ucwords($category); } /** diff --git a/src/AppBundle/Model/Library.php b/src/AppBundle/Model/Library.php index 84a4ec28b0237def91979990088749ed4f39092e..125643e19f2c5b2cad8aac446c1574932a611ff0 100644 --- a/src/AppBundle/Model/Library.php +++ b/src/AppBundle/Model/Library.php @@ -99,6 +99,23 @@ class Library { return $chosen; } + /** + * Gives an array of book objects which match a given category + * + * @param string $category + * + * @return array of Book objects + */ + public function getBooksByCategory($category) { + $books = array(); + foreach ($this->books as $book) { + if ($book->category == $category) { + $books[] = $book; + } + } + return $books; + } + /** * See which books/languages are using a given repository. * diff --git a/src/AppBundle/Resources/views/Read/book_list.html.twig b/src/AppBundle/Resources/views/Read/book_list.html.twig index f69d5d12dc7acfde81efa8450e9e8bd69ee20479..27900ef7f8ea01edad16b8ade8c8832154f5a861 100644 --- a/src/AppBundle/Resources/views/Read/book_list.html.twig +++ b/src/AppBundle/Resources/views/Read/book_list.html.twig @@ -1,5 +1,5 @@