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

    I have re-read ticket 64 only to find out it is meant for 0.9 and not 0.8.

    Is there another way to do this or this can only be achieved in version 0.9 of Akelos?

    Thank you.

    • CommentAuthorrkirkw

    I got it to work. Seems like ticket 64 is suffering a bit from cut-and-paste from a different tutorial

    Follow the first two steps but when you edit app/views/book/listing.tpl do it like below

    {loop books}
        <tr {?book_odd_position}class="odd"{end}>                // <-- After this line
        <td>{book.author.name?}</td>                                // <-- Insert this line
    {loop content_columns}
    • CommentAuthorsuthern

    And if you want a Column header for that, you'll need to do something like this:

    <?php  $content_columns = array_keys($Book->getContentColumns()); ?>         // <-- After this line
    <th scope="col">Author</th>                                                  // <-- Insert this line
    • CommentAuthorccornwell
    Can the sortable_link be applied to joined fields, or only to the associated class' contentColumns?

    Suppose I want the Author column to be sortable? If instead of

    <th scope="col">Author</th>

    I use

    <th scope="col"><?php echo $pagination_helper->sortable_link('what goes here?') ?></th>

    the Author column appears to sort ascending on book.author_id no matter what I put in place of "What goes here?". The single exception is when I substitute 'author_id'. In that case, the page displays 'Author' for the column title, and clicking the column header alternates between ascending and descending sort. But, as before, the sort is on the id, not the name.
    • CommentAuthortilluigi
    i am asking myself the same question here. anybody can help!?
    • CommentAuthortilluigi
    i learned that its not supported by Akelos to sort/order by foreign attribute
    • CommentAuthorallfil4
    <?php echo $pagination_helper->sortable_link('what goes here?') ?></th>

    answer=<?php echo $pagination_helper->sortable_link("Author",array('sort'=>'author_id')) ?></th>

    it worked with 0.9, just like ticket 64 editing the listing method in the book_controller

    this was my sollution:
    in books_controller.php
    function listing()
    $this->book_pages = $this->pagination_helper->getPaginator($this->Book, array('items_per_page' => 10));
    $options = array_merge(array('include'=>'author'),$this->pagination_helper->getFindOptions($this->Book));
    $this->books =& $this->Book->find('all', $options);
    in listing.tpl

    <th scope="col"><?php echo $pagination_helper->sortable_link("Author",array('sort'=>'author_id')) ?></th>
    {loop content_columns}
    <th scope="col"><?php echo $pagination_helper->sortable_link($content_column) ?></th>

    it worked perfectly as i said!!!
    hope can help
    • CommentAuthorhaakon

    Or you cand do the same, just with sintags:

    <th scope="col"><%= sortable_link 'Author', { :sort => 'author_id' } %></th>
    {loop content_columns}
    <th scope="col"><%= sortable_link content_column %></th>

    In my opinion, i'ts often much more easy to read html where you use sintags to use the helpers, than php. It shouldn't give any performance difference anyways, since it is "compiled" and cached until you change it.