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

    First of all I'm new to Akelos, and I have a question about the sortable_link. API says the first argument is the column name. How can I write to the screen a friendly name not the real column name? for example 'Company name' and the column name is 'name' in the database.I hope it is possible.Thanks for the answer.

    regards

    Vektor
    PS: sorry for my english
    •  
      CommentAuthorbermi
     

    Hi Vektor, and welcome to the Akelos forum!

    Column names are provided by AkActiveRecord::getColumnNames() so you can override it in your controller like this:

    function getColumnNames()
    {
        $column_names = parent::getColumnNames();
        $column_names['name'] = $this->t('Company name');
        return $column_names;
    }
    

    In case you don't want column name translations, you can just define the attribute _columnNames in your model with a column => description array

    Regards,

    Bermi

    • CommentAuthorvektor
     
    Hi Bermi,

    thanks a lot, it is easier than i think before.

    GO AKELOS GO GO
    • CommentAuthorvektor
     
    Hi again,

    I put your code to the model, but nothing is changed. You wrote I can override it in the controller, but there is no AkActiveRecord object available right? I forgot to wrote I'm new to oop too

    what was I missed?
    •  
      CommentAuthorbermi
     

    Ok, the sortable link generated by the scaffold uses the keys returned by getContentColumns(), try to use this instead in your views

     $content_columns = $Post->getColumnNames();
    
    •  
      CommentAuthorjulio montoya
     

    In share model .php we can add this function in order that all models could use it

    function getContentColumnsVariable($list)
    {
        $result=array();
    
        $contact_column=$this->getContentColumns();
    
        for($i=0;$i<count($list);$i++)
        {
            if (in_array($list[$i],$contact_column))
            {
                $result[]=$contact_column[$list[$i]];
            }
        }       
        return $list;
    }
    

    And the in the template file we can add this

    <?php
    $list=array('title','firstname','lastname','address','town','zip','telephone','email');
    $content_columns = $Contact->getContentColumnsVariable($list);
    ?>

    {loop contacts} {loop content_columns} get($content_column) ?> {end} link_to_show($contact)?> link_to_edit($contact)?> link_to_destroy($contact)?>
    {end}

    • CommentAuthorKaste
     

    isn't this simply

    array_intersect($list,$this->getContentColumns)
    

    [or another of those hundreds of array_*-functions]

    • CommentAuthorpogeybait4883
     
    I think what you're asking for is something like this:

    <%= sortable_link 'login', {}, :link_text => _('User') %>

    Where the database field is 'login' but you want to show the word 'User'.

    Cheers!