Not signed in (Sign In)
Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
    • CommentAuthorvektor
    • CommentTimeNov 2nd 2007
     
    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
    • CommentTimeNov 2nd 2007
     

    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
    • CommentTimeNov 2nd 2007
     
    Hi Bermi,

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

    GO AKELOS GO GO
    • CommentAuthorvektor
    • CommentTimeNov 2nd 2007
     
    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
    • CommentTimeNov 2nd 2007
     

    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();
    
  1.  

    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
    • CommentTimeJun 23rd 2008
     

    isn't this simply

    array_intersect($list,$this->getContentColumns)
    

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

Add your comments
    Username Password
  • Format comments as