elgg_list_entities output as table

Hi everybody,

i am absolutely beginner, but trying to get an overview by creating my first own plugin.

I have some problems with the output of elgg_list_entities.

I want to set every field in an seperate cell and add in every recordset two own cells with option for delete and edit.

That works fine, but before output my table, elgg places ul and li tags for every recordset.


My code in Page:



$title = "Songliste";
$pagetitle = "Songliste Übersicht";

$content = elgg_view_title($pagetitle);
$content .= elgg_view_menu('songlistbar',array('sort_by'=>'priority', 'class'=>'elgg-menu elgg-menu-admin-control-panel elgg-menu-hz elgg-menu-admin-control-panel-default songlistbar'));
$content .= '<table style="width:100%; border:1px solid #dddddd;"><tr><th>Titel</th><th>Interpret</th><th>Tonart</th><tr>';
$content .= elgg_list_entities(array(
    'type' => 'object',
    'subtype' => 'songliste',
    'owner_guid' => elgg_get_logged_in_user_guid(),
$content .= '</table>';

$body .=  elgg_view_layout('one_column', array('content' => $content));

echo elgg_view_page($title, $body);


and for object calling by elgg_list_entities:


echo '<tr>';
    echo '<td>' . elgg_view('output/text', array('value' => $vars['entity']->title)) . '</td>';
    echo '<td>' . elgg_view('output/text', array('value' => $vars['entity']->interpret)) . '</td>';
    echo '<td>' . elgg_view('output/text', array('value' => $vars['entity']->tonart)) . '</td>';
        //echo '<td>'. $vars['entity']->guid .'</td>';
    echo '<td>';
    echo elgg_view('output/url',array(
       'text' => elgg_echo(''),
       'href' => "action/songliste/edit?guid=" . $vars['entity']->guid ."&forward_url=songliste",
       'class' => "elgg-icon fa elgg-icon-edit fa-edit",
       'confirm' => true,
    echo '</td>';
    echo '<td>';
    echo elgg_view('output/url', array(
   'text' => elgg_echo(''),
   'href' => "action/entity/delete?guid=" . $vars['entity']->guid . "&forward_url=songliste",
   'class' => "elgg-icon fa elgg-icon-trash fa-trash",
   'confirm' => true,
    echo '</td>';
    echo '</tr>';

Where is the error? I don't understand the output.

The first li is bundled in an ul. The rest is issolated li without ul.

I think it is something in my objectfile, but i tried everything to change i could imagine...


Thank you for help and showing the right way.






  • elgg_list_entities() is supposed to output a list of entities as an unordered list with a list item for each corresponding entity and the code of the html output for each item defined in the object view suitable for the type/subtype of the entity. If you want the output of the whole list of entities within a table (one row per entity), usage of elgg_list_entities will not work. Use elgg_get_entities() instead to fetch the entities and then loop through the returned array of entities with foreach() to output the code for each table row (not making use of the object view at all then).

  • So i don't need the object with elgg_get_entities?

    Sorry, but my english is not high level :)

  • Thanks for answering.

    I took a look für rendering a list as a table, but i don't understand the object.

    elgg()->table_columns->getDisplayName ist given only the first column of may recordset.

    How can i output all columns and set an own link for icons?



Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking