Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorFlancer
     
    Hi, I have just discovered Akelos and am trying to learn more about it.

    From the booklink tutorial, it only shows relations between two tables.

    If let's say there is a publisher table, then the book may need a publisher_id.

    In such a case what needs to be changed in the book controller?

    I apologise if I am asking something stupid.... I'm new to MVC too but Akelos' style looks too appealing.

    Thank you
    • CommentAuthorsalavert
     

    If a publisher has many books..

    class Book extends ActiveRecord
    {
        var $belongs_to = array('author', 'publisher');
    }
    
    class Publisher extends ActiveRecord
    {
        var $has_many = array('books');
    }
    

    Now to display book's publisher..

    class BookController extends ApplicationController
    {
        var $models = 'book, author, publisher';
    
        function show()
        {
            $this->Book = $this->Book->find(@$this->params['id'], array('include' => array('author', 'publisher') ));
        }
    
    }
    

    And as usual

    {Book.publisher.name?}
    

    Or if you found an publisher and included it's books..

    {?Publisher.books}
        {loop Publisher.books}
            <p>{Book.name}</p>
        {end}
    {end}
    

    Didn't tested, but should work fine.

    • CommentAuthorFlancer
     
    Thank you for the help. This works well. However I have tried to add to follow the exampled in http://trac.akelos.org/attachment/ticket/64/booklink_appendix.txt to get the overview to show the publisher and the author... but it only shows a blank.

    Also why is the code showing {post.user.login?} and not {book.author.name?} ?
    •  
      CommentAuthorbermi
     

    Flancer, ticket 64 is a proposal a contributor made to improve the booklink tutorial that has not been approved yet and that might have errors, please feel free to correct the proposal with your findings on that same ticket so we can add a valid example instead of a bogus one.