by traveljunkie
First uploaded 519 days ago
0
Recommendations
Summary:
Full description:
Custom index
(Edit your project's description!)
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.
Let me know if there are any problems!
You absolute legend - thank you!
Sean Murricane 519 days ago
Does this keep the login on the main page?
Aaron 519 days ago
This basically gives you a blank frontpage. You'll have to edit content.php to fill it, Aaron.
traveljunkie 519 days ago
Thanks for sharing this. I'm sure i'll have more questions.
kshelton360 519 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
sr123 519 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...
traveljunkie 519 days ago
How to remove the pagination?
Any body please help me how to remove the pagination from the contents in the custom index page
Thanks :-)
Team Webgalli 517 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 516 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:/
if someone can help me it would be great!
Is there a list of all the functions to call (like the last files etc...) ?
Quentinn 516 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...
traveljunkie 516 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())
Quentinn 515 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
traveljunkie 515 days ago
cany you give me a hint to get a view like http:/
??
steven 512 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 504 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!
Camps 501 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
biobak 500 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:/
* @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>
kshelton360 499 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:/
Kind regards,
Rich (HiCR)
CarNut 499 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.
JeremyAlms 499 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);
traveljunkie 493 days ago

Dave
Profile
Friends
Friends of
Pages
Plugins
@traveljunkie - thanks for sharing this. Cheers.
Dave 519 days ago