Update 2
After trying every possible way I could imagine I finally found the solution and I've been pretty close with the version I mentioned in this post.
class BookstoreRouter extends JComponentRouterView
{
public function __construct($app = null, $menu = null)
{
$books = new JComponentRouterViewconfiguration('books');
$this->registerView($books);
$book = new JComponentRouterViewconfiguration('book');
$book->setKey('id')->setParent($books);
$this->registerView($book);
parent::__construct($app, $menu);
$this->attachRule(new JComponentRouterRulesMenu($this));
$this->attachRule(new JComponentRouterRulesStandard($this));
$this->attachRule(new JComponentRouterRulesNomenu($this));
}
public function getBookSegment($id, $query)
{
if (strpos($query['id'], ':') === false) {
$db = JFactory::getDbo();
$dbquery = $db->getQuery(true);
$dbquery->select($db->quoteName('alias'))
->from($db->quoteName('#__bookstore_books'))
->where('id = ' . $db->quote($id));
$db->setQuery($dbquery);
$id .= ':' . $db->loadResult();
}
return array((int)$id => $id);
}
public function getBookId($segment, $query)
{
return (int)$segment;
}
}
In my understanding Nestable was necessary for Parent. Seems I got it all wrong. Works like a charm now.