Adding more parameters Blogs in index.file

Different people code the index file in different ways. Some shows all possible parameters, some don't. What is the code that add pagiigation to Blogs and also specify the number of blogs to be displayed on the main page. The code I have right now is:

        <!-- latest blogs -->
      <div class="index_box">       <div class="pagination">
            <h2><?php echo elgg_echo("custom:blogs"); ?></h2>
                if (isset($vars['area4']))
                    echo $vars['area4']; //display blog posts
                               <a href="/commune/mod/blog/everyone.php/">&nbsp; &nbsp;<b>View all</b></a>

In this style, I have no idea how/where to incorporate the two things I mentioned above.

Can anybody help?

  • That view is being called from another view.  That bit of code alone doesn't show any blog posts.

    What version of Elgg are you using?  If it's 1.7 or higher you want something like:

    $options = array(

    'type' => 'object',

    'subtype' => 'blog',

    'limit' => 20 // how many you want to show,

    'full_view' => false // set to true if you want to show the entire posts


    echo elgg_list_entities($options);

  • Brett, Is this a stand-alone? Or is to be added to the existing script?

    I am using 1.7.4. And what I meant is new_idex.php.


  • @woodpecker

    You can get some idea by taking a look at /mod/custom_index/index.php

    I am now working at a site where the new_index.php doesn't specify the number of blogs to be displayed, and yet it was a fixed number. I found that this number is specified at the above file. This is also applicable to groups, bookmarks, etc. You can also add pagination (true) here.

  • Juipo

    woodpecker,  the code Brett is telling you is inside custom_index plugin.

    Code you posted :

    if (isset($vars['area4']))

    calls area4 which is defined in custom_index plugin.  Our theme you are using only uses a view file (new_index.php) to override the view (and most other themes).

    Open start.php and either replace existing code with one that Brett gave you or just adjust number of blogs. ;-)

    Pagination, will require more code.

  • Juipo, I got a better picture of things after reading shillo's note, and my main page reflects it now. What Brett wrote is clearer to me after that reading Shillo. Only I din't know how to incorporate it into proper syntax until I read Shillo.

    Steven's pages showed me how to put two things that are uncommon in main page: latest activity and latest discussion. I have already put it in the new_page index. My present main page is a mix of the 2 sources mentioned above as you can see.

    I prefer to concentrate on /mod/custom_index/index.php. It is short, easy wo work with, but have no idea how to include activities and discussions in the same way. for instance:

    $blogs = elgg_list_entities(array('type' => 'object', 'subtype' => 'blog', 'limit' => 5, 'pagination' => TRUE,'full_view' => FALSE, 'view_type_toggle' => FALSE, ));

    How you put activities and discussion in the same simple one-line code? I will be happy if you can show me the proper syntax. If i get an answer, I will put 3 of each main page items, using pagination. That gives the users an idea of what are inside, and the pagination gives the otherwise bland main page a new professional look.


  • You'll need to specify the types for each object you want to see.  The options array you pass to elgg_list_entities() would look something like:

    $options = array(

            'type' => 'object',

            'subtypes' => array('blog, 'groupforumtopic'),

            'limit' => 5, 

            'full_view' => false,
            'view_type_toggle' => false


    This will only show the latest forum topics.  That's because forum posts are annotations and use different getter functions.

  • Someone I contrived a main page. You can see it at .

    Thanks for everything, brett.

    I only have one doubt. Actually I want only a slideshow along with login/member photo boxes to begin with. But if someome logins, they can see the whole main page as it is now. Which means, can I create another file say, index2.php) with all those items and use the login redirector plugin to lead the logged in user to this page?

  • No need, in the index page use

    if isloggedin { show the content for logged in users } else { content for non logged in users}. So Simple!!

  • @ Team Webgalli

    Thanks for the suggestion.

    I am aware that it is the easiest way, but the new-index is  a long file with <> and {} at many places. I am scared to to handle it. With my scanty coding ability It would mean a long trial-and-error series. I am trying to get a dropdown login menu; if I get it, my opening page will have only that slide show.