How to add The wire and River to custom_index.php page.(period)

I took more than one week to find out how to do this, searched everywhere, even in other websites. Yes, I'm new to elgg.

Here is a relief for many people, even for people who makes plugins, I know it's a relief cause I've seen a lot of people here and out of here asking how to do this.

I didn't develop this, those are parts that I took from elgg files and made a minimum alteration to display the wire and the activities in the custom index Working 100% (at least for me), the only issue I saw is that a few functions redirect the user to the wire page and I still don't know how to solve that. If you find some bugs, or can help with you the code, I already say "Thanks in advance". =D

Wish you success. ; )

 

You can see it working here: http://suachance.lucrebem.com.br/

 

 

             <?

// Check if user is logged in, so he can see the wire form and wire posts

             if (elgg_is_logged_in()) 

 

{

 

//Change to whatsoever message you want to display before the form

echo '<p><strong>Say hi to the world</strong></p>';

 

// call the wire form (Micro-Blog)

echo elgg_view_form('thewire/add');

 

/"

Call the wire content, I put it to display 3 items only, if you want to display more items, just change the number in: 'limit' => 3,

*/

 

/*

 * User wire post widget display view

 */

$num = $vars['entity']->num_display;

 

$options = array(

'type' => 'object',

'subtype' => 'thewire',

'container_guid' => $vars['entity']->owner_guid,

'limit' => $num,

'full_view' => FALSE,

'pagination' => TRUE,

'limit' => 3,

);

$content = elgg_list_entities($options);

 

echo $content;

 

if ($content) {

$owner_url = "thewire/owner/" . elgg_get_page_owner_entity()->username;

$more_link = elgg_view('output/url', array(

'href' => $owner_url,

'text' => elgg_echo('thewire:moreposts'),

));

echo "<span class=\"elgg-widget-more\">$more_link</span>";

} else {

echo elgg_echo('thewire:noposts');

}

 

//closes the login function.

}

?>  

 

 

<!-- Display the users activities -->  

      <p><strong>

Users activities</strong></p>

<?

/**

 * Activity widget content view

 */

 

$num = (int) $vars['entity']->num_display;

 

$options = array(

'limit' => $num,

'pagination' => false,

);

 

if (elgg_in_context('profile')) {

$options['subject_guid'] = elgg_get_page_owner_guid();

} else {

if ($vars['entity']->content_type == 'friends') {

$options['relationship_guid'] = elgg_get_logged_in_user_guid();

$options['relationship'] = 'friend';

}

}

 

$content = elgg_list_river($options);

if (!$content) {

$content = elgg_echo('river:none');

}

 

echo $content;

?>

 

 

 

 

 

 

Done. You can use this in your custom index page.