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
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)
I have the same problem but when the patches are applied (all four) there is a different error:
Fatal error: Cannot redeclare class PaginationHelper in /usr/local/web/akelos_framework/lib/AkActionView/helpers/pagination_helper.php.bak on line 144
I have been going through the changes introduced by the patches and they seem fine.
The Akelos framework versions tested were 0.8 (stable) and a repository tarball downloaded on 2008-09-29.
Any suggestion on what is going on and how to solve it would be greatly appreciated.
Found the culprit: In the helpers directory, there were pagination_helper.php and pagination_helper.php.bak files each defining the class PaginationHelper. I did not realized the *.bak files were included too.
1 to 5 of 5