Log in

Stats

  • Category: Uncategorized
  • License: GNU General Public License (GPL) version 3
  • Updated: 2010-1-14
  • Downloads: 9440
  • Recommendations: 10

Releases


Previous releases:

Custom index for Elgg 1

Last updated 2008 days ago

Custom index


(Edit your project's description!)

Release Notes:

Since the question on how exactly to make a custom front page popped up quite often now, here's the code I have made for my own install. You'll still have to modify it a bit.

  • If you don't want to attach your own scripts and/or styles to the head then delete these two lines in start.php:
    extend_view('metatags','customindex/metatags');
    extend_view('css','customindex/css');
  • In index.php edit the last line to what you want your titel to be (up in the browser bar)
  • Edit all files in views/default/customindex:
    • content.php will be the content of your page
    • metatags.php will be the extra scripts you want to put in the head
    • css.php are all the extra styles you want to apply
  • There are a lot more things you can do, like setting a page title or changing the layout from one column to two columns, but that's up to you. These files are basically what I am using on my site, not including the scripts and styles.

Let me know if there are any problems!

Comments

  • Sean Murricane 2008 days ago

    You absolute legend - thank you!

  • Aaron 2007 days ago

    Does this keep the login on the main page?

  • traveljunkie 2007 days ago

    This basically gives you a blank frontpage. You'll have to edit content.php to fill it, Aaron.

  • marcrocs 2007 days ago

    Thank-You

  • kshelton360 2007 days ago

    Thanks for sharing this. I'm sure i'll have more questions.

  • sr123 2007 days ago

    Thanks for this traveljunkie.

    Could you give us an example of a contents.php file, one that pulls some stuff out of the elgg database (for instance, the latest users, activity, etc.)?

    You said:

    There are a lot more things you can do, like setting a page title or changing the layout from one column to two columns, but that's up to you. These files are basically what I am using on my site, not including the scripts and styles.


    I noticed in the index.php that you have:

     

          // Format
            $body = elgg_view_layout('one_column', $area1);

     

    I'm assuming this somehow correlates with what someone would place in contents.php, right?

     

    I guess what I need is an understanding of how what's in the contents.php file correlates to the index.php file, and how to put useful things into the contents.php.

     

    Sorry if any of what I am saying appears silly.  I suppose I learn best from examples.

     

    And last but not least, how do you disable the plugin if you enabled it without first creating a contents.php file (like I did... lol).

    Regards,
    sr123

  • traveljunkie 2007 days ago

    $area1 is the content you put into contents.php. that $body bit tells elgg to take that $area1 and put it into the one_column layout. So whatever you put into contents.php will automatically be put in between the header and the footer.

    As for an example... This would get you the latest 36 site members:

    $users = get_entities('user', '', 0, '', 36, 0, false, 0, null);
    if($users){
    foreach($users as $user){
    echo "<div class="\"member_icon\"">" . elgg_view("profile/icon",array('entity' => $user, 'size' => 'small')) . "</div>";
    }
    }

    This puts the login form on your frontpage:

    $form_body = "<p><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label><br />";
    $form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
    $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . "</p>";
    $form_body .= "<p><a href=\"". $vars['url'] ."account/register.php\">" . elgg_echo('register') . "</a> | <a href=\"". $vars['url'] ."account/forgotten_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";

    echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));

    And this here gets you the latest 12 items of the site activity

    set_context('search');
    $content = list_registered_entities(0,12,true,false,array('object','group'));
    $content = elgg_view_layout('', '', $title . $content);
    
    echo $content;
    

    Of course you'll still need to add the php tags around these examples and package it all up nicely in some divs and present it with some css to the world.

    Hmm, did you try deleting the plugin? That should work. If not, then just copy that login form into contents.php, load it up, log in and deactivate...

    Hope that helps...

  • Quentinn 2004 days ago

    hi thanks for this plugin!

    I managed to override the dashboard also with your plugin!

    But I have one question: how do you set the two columns display?

    I have put that:

    // Format
        $body = elgg_view_layout('two_columns', $area1);

     

    One more question: can someone tell me how to NOT display the login form once the user is logged in?

    thanks.

    Once I've finished, I'll put my theme on the site.

  • Quentinn 2004 days ago

    I managed to customize as I wanted the page but I have another problem:

    I tried to put your code to show the members but it is not right apparently a problem with

    "<div class="\"member_icon\"">"

    I put that instead, it is workign but i dont have the dropping menu on the icon (it is at the other side of the div)

    <div id="utilisateurs">
        <h2>Utilisateurs</h2>
        <?php
    $users = get_entities('user', '', 0, '', 2, 0, false, 0, null);

    if($users){
       foreach($users as $user){
          echo "<div class='\'member_icon'\'>" . elgg_view("profile/icon",array('entity' => $user, 'size' => 'small')) . "</div>";
       }
    }
    ?>
    </div>

    you can see it here:

    http://etudiants.sciencespoaix.com/

    if someone can help me it would be great!

    Is there a list of all the functions to call (like the last files etc...) ?

  • traveljunkie 2004 days ago

    Yeah. That code should read "<div class=\"member_icon\">". Seems like a copy'n'paste error to me. No idea where those extra quotes  came from...

    You can't use this plugin to change the dashboard. Instead make a new plugin, name it customdash and put this in start.php:

    	/**
    	 * Elgg customdash plugin
    	 * This plugin substitutes the dashboard with a custom one
    	 * 
    	 * @package Customdash
    	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
    	 * @author Boris Glumpler
    	 * @copyright Boris Glumpler 2008
    	 * @link /travel-junkie.com
    	 */
    
    	function dash_init() {
    
    		register_page_handler('dashboard','dash_page_handler');
    		extend_view('metatags','customdash/metatags');
                    extend_view('css','customdash/css');
    
    
    	}
    
    	function dash_page_handler($page) {
    
    		@include(dirname(__FILE__) . "/index.php");
    
    	}
    
    	register_elgg_event_handler('init','system','dash_init');
    

    Then adjust content.php accordingly...

  • Quentinn 2004 days ago

    thanks.

    I was not sure of the syntax.

    However,  it seems that my start.php fo customindex can override the dashboard!

    function customindex_init() {

            register_plugin_hook('index','system','new_index');
            extend_view('metatags','customindex/metatags');
            extend_view('css','customindex/css');

        }

        function new_index() {

            if (!@include_once(dirname(dirname(__FILE__))) . "/customindex/index.php") return false;
            return true;

        }

        register_elgg_event_handler('init','system','customindex_init');
       
       
        function dash_init() {
       
            // Extend system CSS with our own styles
                   extend_view('css','customindex/css');
                   
            // Register a page handler, so we can have nice URLs
                register_page_handler('dashboard','dash_page_handler');
                   
        }
       
        /**
             * Dashboard page handler; allows the use of fancy URLs
             *
             */
        function dash_page_handler($page) {
               
            @include(dirname(__FILE__) . "/index.php"); //this will be your new dashboard page
               
        }

        // Make sure the
                register_elgg_event_handler('init','system','dash_init');
       
       
    ?>

    It is working, the only thing that is not right is the login form which is not disappearing (what is the syntax to check if the user is logged in? , if so i want to display a text instead of the form.

    if (isloggedin()) 
  • traveljunkie 2003 days ago

    Quentinn, just make it a new plugin. It'll be easier. Right now you're using the same page as your index page and your dashboard. Having a plugin for each will give you greater control.

    if (isloggedin()) {
    //do stuff
    } else {
    //do some other stuff
    }

    If you really want to keep it in the same plugin then the above code should do the trick

  • steven 2001 days ago
  • chiinook 1993 days ago

    I'd like to include the cool DIY Map on the index of my site and am having a hard time getting it to show up. Wondering if you have any advice. The DIY Map website instructs the insertion of the code below in order to embed the map. Two files are called: the map file (eg world.swf) and the data file (eg world.eml). Given the embed code I've pasted below, how would you integrate these on the index page?

    <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
    codebase="http://download.macromedia.com/pub/
    shockwave/cabs/flash/swflash.cab#version=7,0,0,0"
    width="550" height="300" id="zoom_map" align="top">
    <param name="movie" value="world.swf" />
    <param name="quality" value="high" />
    <param name="bgcolor" value="#FFFFFF" />
    <embed src="world/world.swf" quality="high" bgcolor="#FFFFFF"
    width="550" height="300" name="Clickable World Map" align="top"
    type="application/x-shockwave-flash"
    pluginspage="http://www.macromedia.com/go/getflashplayer">
    </embed>
    </object>

    A second question refers to a problem raised by another commenter and solved before you could respond. How do I keep the 2 column left sidebar layout and use the larger, right-hand column for the contents file?

  • chiinook 1991 days ago

    OK ... I've been able to get the embed code to work but I'm still having trouble calling up the two necessary files. I've styled the div to show where the map ought to show up. You can see what I've got so far here. Any suggestions?

  • chiinook 1991 days ago

    done ... not pretty just yet but working.

    check it out at the link above.

  • Camps 1990 days ago

    Hello, I would like to have an home page that looks like a magazine by show latest admin's blog post, a login form, recent activities and a list of members....how can I do that?

    Thanks!

  • biobak 1988 days ago

    Hello, thanks for the plugin. 

    In yout introduction you speak of converting the start page to a two column page... since I'm new to Elgg, can you show me (us) how this is done?

    Thanks in advance 

    Biobak

  • kshelton360 1988 days ago

    ok. This is the code that I decided to use to create my custom index page however, the page comes up blank. it's not pulling the code. What am I doing wrong???

    ok. this is the code that I have decided to use to configure my index page however, it gives me a blank page.  what could I be doing wrong?

    <?php
     /**
      * Elgg customindex plugin
      * This plugin substitutes the frontpage with a custom one
      *
      * @package Customdash
      * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
      * @author Boris Glumpler
      * @copyright Boris Glumpler 2008
      * @link /travel-junkie.com
      */

     // Put your content below

    /**This is the section that should create the login and welcome box*/

    <div id="welcome-box">
    <div id="login-box">
    <?php
    $form_body = "<p><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label><br />";
    $form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
    $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . "</p>";
    $form_body .= "<p><a href=\"". $vars['url'] ."account/register.php\">" . elgg_echo('register') . "</a> | <a href=\"". $vars['url'] ."account/forgottn_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";

    echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));
    ?>

    </div>

    <h2>Welcome to my social website</h2>
    <p>This is where my text will go in the txt box...blah blah blah....</p>
    </div>

    /**This is the section that should show the newest members*/

    <div id="newest-members">
    <h2>Newest Members</h2>
    <?php

    $users = get_entities('user', '', 0, '', 25, 0, false, 0, null);
    if($users){
       foreach($users as $user){
          echo "<div class=\"member_icon\">" . elgg_view("profile/icon",array('entity' => $user, 'size' => 'small')) . "</div>";  
       }
    }

    ?>
    </div>

    /**This is the section that should show the latest-groups*/

    <div id="latest-groups">
    <h2>Latest Groups</h2>
    <?php

    $groups = get_entities('group', '', 0, '', 25, 0, false, 0, null);
                    if($groups){
                        foreach($groups as $group){
                              echo "<div class=\"member_icon\">" . elgg_view("profile/icon",array('entity' => $group, 'size' => 'small')) . "</div>";  
                        }
                    }
    ?>
    </div>

    /**This is the section that should show the latest-activity*/

    <div id="latest-activity">
    <h2>Latest Activity</h2>
    <?php
    set_context('search');

    $content = list_registered_entities(0,12,true,false,array('object','group'));

    $content = elgg_view_layout('', '', $title . $content);

    echo $content;
    ?>

    </div>

     


     

  • CarNut 1987 days ago

    Hello traveljunkie,

    I'm brand new here. (from Holland) I hope to get some help from you people. Few days ago I downloaded Elgg v.1.1 and it seems to be really new so not much, if not nothing, is written about this new version.

    Does any of you know what page(s) I need to edit to change the frontpage (shown to visitors before logging on). The items on this issue are not helping me at all. I can not find a /customindex/directory/ and the welcome.php is not working. For all I know my frontpage just occured on my screen after installing.

    The script is working fine, as far as I can tell. (http://www.carnut.nl)

    Kind regards,

    Rich (HiCR)

  • JeremyAlms 1987 days ago

    @kshelton -

    [code]



    <div id="welcome-box">
    <div id="login-box">
    <?php
    $form_body = "<p><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label><br />";
    $form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
    $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . "</p>";
    $form_body .= "<p><a href=\"". $vars['url'] ."account/register.php\">" . elgg_echo('register') . "</a> | <a href=\"". $vars['url'] ."account/forgottn_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";

    echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));
    ?>

    </div>

    <h2>Welcome to my social website</h2>
    <p>This is where my text will go in the txt box...blah blah blah....</p>
    </div>

    /**This is the section that should show the newest members*/

    <div id="newest-members">
    <h2>Newest Members</h2>
    <?php

    $users = get_entities('user', '', 0, '', 25, 0, false, 0, null);
    if($users){
       foreach($users as $user){
          echo "<div class=\"member_icon\">" . elgg_view("profile/icon",array('entity' => $user, 'size' => 'small')) . "</div>"; 
       }
    }

    ?>
    </div>

    /**This is the section that should show the latest-groups*/

    <div id="latest-groups">
    <h2>Latest Groups</h2>
    <?php

    $groups = get_entities('group', '', 0, '', 25, 0, false, 0, null);
                    if($groups){
                        foreach($groups as $group){
                              echo "<div class=\"member_icon\">" . elgg_view("profile/icon",array('entity' => $group, 'size' => 'small')) . "</div>"; 
                        }
                    }
    ?>
    </div>

    /**This is the section that should show the latest-activity*/

    <div id="latest-activity">
    <h2>Latest Activity</h2>
    <?php
    set_context('search');

    $content = list_registered_entities(0,12,true,false,array('object','group'));

    $content = elgg_view_layout('', '', $title . $content);

    echo $content;
    ?>

    </div>



    [/code]

     

    You had an open php tag, replace entire content.php with the above.

  • Chuck 1983 days ago

    Hi, could anybody explain me how to build 2 columns? 

    Thanks

  • traveljunkie 1981 days ago

    Ok, if you want two columns then just change in index.php this line

    $body = elgg_view_layout('one_column', $area1);

    to this

    $body = elgg_view_layout('two_column_left_sidebar', $area1);
  • Wayward 1981 days ago

    Hey thanks for the plugin. I just had a couple questions.

    1. Might be a dumn one. Where does this look for its css. Will it read from ,y themes css file or must i put any styling for customindex into the customindex css file under its views folder?
    2. I took your tip for making the 2 column layout from your comment above. But all my content goes to the first left column now. How do I popolate both.

    Many thanks for any assistance. This is a great plugin Its just going to take me a little bit to learn it:)

  • wolkenlos 1981 days ago

    hi!

    my example for the content.php - solution with tables - maybe useful for somebody

    kind regards
    wolkenlos

    <html>
    <head>
    <title>Your page title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>

    <body text="#000000" bgcolor="#FFFFFF">
    <div align="center">
      <table width="928" border="0">
        <tr>
          <td width="286" height="249"> Login<br>
            <br>
            <?php
    $form_body = "<p><label>" . elgg_echo('username') . "<br />" . elgg_view('input/text', array('internalname' => 'username', 'class' => 'login-textarea')) . "</label><br />";
    $form_body .= "<label>" . elgg_echo('password') . "<br />" . elgg_view('input/password', array('internalname' => 'password', 'class' => 'login-textarea')) . "</label><br />";
    $form_body .= elgg_view('input/submit', array('value' => elgg_echo('login'))) . "</p>";
    $form_body .= "<p><a href=\"". $vars['url'] ."account/register.php\">" . elgg_echo('register') . "</a> | <a href=\"". $vars['url'] ."account/forgottn_password.php\">" . elgg_echo('user:password:lost') . "</a></p>";

    echo elgg_view('input/form', array('body' => $form_body, 'action' => "". $vars['url'] ."action/login"));
    ?>
            <br>
            <font color="#CCCCCC">---------------------------------------</font><br>
            <b>Last 25 Users:</b><br>
            <br>
            <?php

    $users = get_entities('user', '', 0, '', 25, 0, false, 0, null);
    if($users){
       foreach($users as $user){
          echo "<div class=\"member_icon\">" . elgg_view("profile/icon",array('entity' => $user, 'size' => 'small')) . "</div>";
       }
    }

    ?>
            <br>
            <br>
            <br>
            <font color="#CCCCCC">---------------------------------------</font><br>
            <b>New Groups:</b><br>
            <br>
            <?php

    $groups = get_entities('group', '', 0, '', 25, 0, false, 0, null);
                    if($groups){
                        foreach($groups as $group){
                              echo "<div class=\"member_icon\">" . elgg_view("profile/icon",array('entity' => $group, 'size' => 'small')) . "</div>";
                        }
                    }
    ?>
            <br>
            <br>
            <br>
            <font color="#CCCCCC">---------------------------------------</font> <br>
            <br>
            <br>
          </td>
          <td width="438">
            <table width="100%" border="0">
              <tr>
                <td>
                  <?php
    set_context('search');

    $content = list_registered_entities(0,12,true,false,array('object','group'));

    $content = elgg_view_layout('', '', $title . $content);

    echo $content;
    ?>
                  <div align="right"></div>
                </td>
              </tr>
            </table>
          </td>
          <td width="6" valign="top">&nbsp;</td>
          <td width="215" valign="top"><font color="#000000"><b>In Kooperation mit:</b></font><br>
            <br>
            <img src="http://www.mydomain.com/network/mod/customindex/views/default/customindex/banners/pic.png" width="215" height="60">
          </td>
        </tr>
      </table>
    </div>
    </body>
    </html>