How to present objects as Gallery or table using elgg_list_entity

    enRaiser
    By enRaiser

    elgg_list_entiy presents the object as a collection of <li> tag under <ul> tag. thus particularly modifying  style will impact the whole site. so generally developers tries to  bypass this functions and write its own code. but then he has to implement everything like pagination, and sql stuff.

     
    Here I will show how one can still use elgg_list_entities and achieve a desired representation.
    elgg_list_entity has a parameter called ‘list_class‘ and ‘item_class‘   . ELGG will append the values of list_class to ul tag and item_class to li tag.
     
    (1) a Table representation.
    You can’t replace ul tag to table tag and li tag to tr tag .but there is a facility in CSS using which u can still achieve this. thats display,
    you can write table/ table-row or table-cell again any entity to make it look like table,tr,td

    <style type="text/css">

    .table_order_list {

     display:table;

    border-collapse: collapse;

    }

    .table_order_item {

    display: table-row;

    }

    </style>

     

    $options = array('types' => 'object',

    'subtype' => 'subtype',

                             'list_class'=> 'table_order_list',

                             'item_class' =>'table_order_item'

    );

    echo elgg_list_entities($options);

    These way you can  achieve a table representation of elgg_list_entities.

     

    (2) gallery representation

    If you add  ‘list_type’=>’gallery’ as parameter then elgg will try to represent object in gallery form. and to further achieve  afire tuning  as per your need you can use  gallery_class and item_class. ELGG will append the values of gallery_class to ul tag and item_class to li tag.

     

     

    $options = array('types' => 'object',

    'subtype' => 'subtype',

     'gallery_class'=> 'my gallery_ul',

                             'item_class' =>'my_gallery_item'

    );

    echo elgg_list_entities($options);