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

    I want to fetch all records(destination names) from a table(destinations) n show it in the views.

    Code:

    $this->usa = $this->Destination->find('all', array('offset' => 10, 'limit' => 10, 'offset' => 1)); (in controller)

    index.tpl:
    {?usa}
    <p><a href="#"><%= textilize destination.name %></a></p>
    {end}
    Let me know where i went wrong?
    • CommentAuthorKaste
     

    usa holds an array (find all!) of Destination-objects. so you have to loop over usa. (foreach-loop)

    if you can make up a different name for the variable usa, a name that is countable you could use sintags f.i.

    {loop destinations}

    {end loop}

    this would be

    $this->Destinations = ...
    

    in the controller

    • CommentAuthorGKSR
     
    thanks Kaste. The destinations array has 50 USA states. now i want to divide them in 3 columns having 17 rows each.
    But If i use:
    {loop usa}
    <p>{usa.name}</p>
    {end}
    it prints all the 50 states.
    At the same time, i can't use limit in find() bcause of this i need to use 3 queries, this inturn increases the no of connections to the dbase. so what i want is fetch all states in a single query(done), But divide the loop into 17*3?
    did u get me???
    • CommentAuthorKaste
     

    inside the sintags-loop you have following variables

    ${:singular_name}_loop_key
    ${:singular_name}_loop_counter
    ${:singular_name}_is_first
    ${:singular_name}_is_last
    ${:singular_name}_odd_position
    

    the rest depends on the html you have to generate.