Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorpogeybait4883
     
    It seems like sortable_link works well if you are pulling data from only one database but what happens if you have to do a look-up on one of the fields? Consider the following model for my activity log. It has the following fields in the database:
    id,
    user_id int(11),
    ip_address varchar(255),
    controller varchar(255),
    action varchar(255),
    params text

    The user_id is obvisously an integer representing a user_id so in my view I would need to do a look-up to get the user login or user name based on that id. I'm going to paste my listing.tpl view and I was wondering if anyone could tell me how to sort on the user field. See below for the code:

    <div id="comment-listing" class="action listing">
    <h1>_{Manage Contest}</h1>
    <h2>_{Contest Activity Log}</h2>
    {?activity_logs}
    <table>
    <tr>
    <th>_{User}</th>
    <th><%= sortable_link 'ip_address', {}, :link_text => _('IP Addr') %></th>
    <th><%= sortable_link 'controller', {}, :link_text => _('Controller') %></th>
    <th><%= sortable_link 'action', {}, :link_text => _('Action') %></th>
    <th><%= sortable_link 'params', {}, :link_text => _('Params') %></th>
    </tr>
    {loop activity_logs}
    <? $log_user =& $CurrentContest->user->find( 'first', array('conditions'=>array( 'id = ?', $activity_log->user_id ) ) ); ?>
    <tr>
    <td>{log_user.login}</td>
    <td>{activity_log.ip_address?}</td>
    <td>{activity_log.controller?}</td>
    <td>{activity_log.action?}</td>
    <td>{activity_log.params?}</td>
    </tr>
    {end}
    </table>
    {?activity_log_pages.links}
    <div id="AddressPagination">
    <div id="paginationHeader"><?php echo translate('Showing page %page of %number_of_pages',
    array('%page'=>$activity_log_pages->getCurrentPage(),
    '%number_of_pages'=>$activity_log_pages->pages))?></div>
    {activity_log_pages.links?}
    </div>
    {end}

    {else}
    <p>_{No activity has been logged at this time.}</p>
    {end}

    </div>



    Thanks!
    -- pogeybait4883