Commit 288a1454 authored by Sean Madsen's avatar Sean Madsen

Book categorization to close #30

parent 16e2d7fc
name: Developer guide
weight: 10
description: For CiviCRM developers
category: Core
langs:
en:
repo: 'https://github.com/civicrm/civicrm-dev-docs'
......
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'
......
......@@ -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'),
)
);
}
......
......@@ -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);
}
/**
......
......@@ -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.
*
......
<ul class="books">
{% for book in library.books %}
{% for book in books %}
<li class="book">
<span class="name">
{% if book.isMultiLanguage or book.languages|first.isMultiVersion %}
......
......@@ -21,8 +21,12 @@
installation and upgrades</a>
is still on the wiki.</em></p>
<h2>Books</h2>
<h2>Core Books</h2>
{% include 'AppBundle:Read:book_list.html.twig' %}
{% include 'AppBundle:Read:book_list.html.twig' with {books: core_books} %}
<h2>Extensions Books</h2>
{% include 'AppBundle:Read:book_list.html.twig' with {books: extensions_books} %}
{% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment