Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    •  
      CommentAuthorfrancois
    • CommentTimeJan 28th 2008 edited
     

    Hello everybody,

    First, thank you for this framework.

    I'm a beginner with Akelos framework and i'm trying to develop a little application. I started with the tutorial sample Booklink.

    The problem append when i try to show the author_name in the book's listing and then try to order my result list. Below the error message :

    " Fatal error: Call to undefined method Book::getAvailableAssociates() in D:\dev\ide\workspace\akelos\lib\AkActionView\helpers\pagination_helper.php on line 89 "
    

    Here you have the source code of the models Book and Author

    class Book extends ActiveRecord
    {
        var $belongs_to = 'author'; 
    }
    
    class Author extends ActiveRecord
    {
        var $has_many = 'books';
    }
    

    Here he source code of the BookController

    class BookController extends ApplicationController
    {
        var $models = 'author'; 
        var $app_helpers = 'layout';
        function index()
        {
            $this->renderAction('listing');
        }
    
        function listing()
        {
            $this->book_pages = $this->pagination_helper->getPaginator($this->Book,
            array(
                'items_per_page' => 5
                ,'include' => 'author')
            );        
    
            $this->books = $this->Book->find('all', $this->pagination_helper->getFindOptions($this->Book));
        }
    
        function show()
        {
            $this->book = $this->Book->find(@$this->params['id'], array('include' => 'author'));
        }
        function add()
        {
            if(!empty($this->params['book'])){
                $this->Book->setAttributes($this->params['book']);
                if ($this->Request->isPost() && $this->Book->save()){
                    $this->flash['notice'] = $this->t('Book was successfully created.');
                    $this->redirectTo(array('action' => 'show', 'id' => $this->Book->getId()));
                }
            }
        }
    
        function edit()
        {
            if (empty($this->params['id'])){
             $this->redirectToAction('listing');
            }
            if(!empty($this->params['book']) && !empty($this->params['id'])){
                $this->book->setAttributes($this->params['book']);
                if($this->Request->isPost() && $this->book->save()){
                    $this->flash['notice'] = $this->t('Book was successfully updated.');
                    $this->redirectTo(array('action' => 'show', 'id' => $this->book->getId()));
                }
            }
        }
    
        function destroy()
        {
            if(!empty($this->params['id'])){
                $this->book =& $this->Book->find($this->params['id']);
                if($this->Request->isPost()){
                    $this->book->destroy();
                    $this->redirectTo(array('action' => 'listing'));
                }
            }
        }  
    }
    

    And then the listing template listing.tpl

    <div id="sidebar">
      <h1>_{Tasks}:</h1>
      <ul>
        <li><?php  echo  $url_helper->link_to($text_helper->translate('Create new Book'), array('action' => 'add'))?></li>
      </ul> 
    </div>
    
    <div id="content">
      <h1>_{Books}</h1>
    
      {?books}
      <div class="listing">
      <table cellspacing="0" summary="_{Listing available Books}">
    
      <tr>
        <?php  $content_columns = array_keys($Book->getContentColumns()); ?>
    
        {loop content_columns}
            <th scope="col"><?php  echo  $pagination_helper->sortable_link($content_column) ?></th>
        {end}
        <th scope="col"><?php  echo  $book->author->name ?></th>
        <th colspan="3" scope="col"><span class="auraltext">_{Item actions}</span></th>
      </tr>
    
      {loop books}
        <tr {?book_odd_position}class="odd"{end}>
        {loop content_columns}
          <td class="field"><?php  echo  $book->get($content_column) ?></td>
    
    
        {end}
        <td><?= $url_helper->link_to($book->author->name, array('controller'=>'author', 'action'=>'edit', 'id'=>$book->author->getId())) ?></td>
        <td class="operation"><?php  echo  $book_helper->link_to_show($book)?></td>
          <td class="operation"><?php  echo  $book_helper->link_to_edit($book)?></td>
          <td class="operation"><?php  echo  $book_helper->link_to_destroy($book)?></td>    
        </tr>
      {end}
       </table>
      </div>
      {end}
    
        {?book_pages.links}
            <div id="BookPagination">
            <div id="paginationHeader"><?php  echo translate('Showing page %page of %number_of_pages',array('%page'=>$book_pages->getCurrentPage(),'%number_of_pages'=>$book_pages->pages))?></div>
            {book_pages.links?}
            </div>
        {end}
    
    </div>
    

    If someone have the response, i will appreciate a lot ?

    Thanks in advance Francois

    • CommentAuthorKaste
    • CommentTimeJan 28th 2008
     

    I think we have a ticket for this here

    Please give us some feedback if the proposed patch solves the issue. (We don't have tests for this issue)

    •  
      CommentAuthorfrancois
    • CommentTimeJan 29th 2008
     
    Thank you Kate

    The patch solves the issue.
Add your comments
    Username Password
  • Format comments as