Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthormkhatib
     

    Hello Everyone, I am new to the akelos framework, and i am finding hard time to follow the documentation of akelos. Anyways, here's my problem: I have 3 models, Blog ( so anyone can create his own blog ), Post , and User, i've all the Association set, i was able to do this: {loop blog.posts} {post.title} {post.body} {end} After I've Included the posts, in the blog_controller in the show function, something like: $this->blog = $this->Blog->find($this->params[:id], array('include'=>array('posts'))) This works just fine. What i want to do, is to display the user that has posted the post, I've already set the association between the post and the user (post belongs_to user) and ( user has_many posts ), the following does not work! {loop blog.posts} {post.title} {post.user.name} {post.body} {end}

    It gives me the following error:

    Undefined property: AkAssociatedActiveRecord::$name.

    name is the database column in the users table.

    I hope you can help me in this. I really need to get with akelos.

    • CommentAuthormkhatib
     

    I Found a way around of doing this, but still couldn't do the double association post.user.title. What i did to get the users in the blog_controller in method show: $this->posts = $this->EditorialBlog->post->find('all', array('include'=>array('user'))); and in the show.tpl: {loop posts} {post.title} Posted By: {post.user.name} @ {post.created_at} {post.body} That worked like a charm!

    I am still wondering if akelos can handle something like:

    post.user.comments

    comment.post.user.comments

    picture.post.comments

    Like Rails can :) ...

    Regards...

    • CommentAuthorKaste
     

    unfortunately this is not possible. due to PHP4 we dont have that much laziness. but I really would like to see this.

    foreach ($this->posts as $post){
        $post->user->comment->load();
    }
    

    something like this will do the trick.

    (Is it really posts => users => comments?)

    • CommentAuthorKaste
     

    just wanna add:

    class User...
    function getComments()
    {
        if (empty($this->comment->_loaded)){
            $this->comment->load(); 
        }
        return $this->comments;
    
    }
    

    Right now Sintags won't call getComments. But I think it's good to post this approach anyway.

    (->get('comments') will call getComments() BTW!)

    • CommentAuthormkhatib
     

    Really! Waw ... Nice one .. Thanks Kaste :D ...