http://docs.elgg.org/wiki/Views
For a more detailed explanation - also very useful when starting plugin development or in case you only intend to customize your site a bit:
http://www.packtpub.com/elgg-18-social-networking/book
http://www.amazon.com/Elgg-Social-Networking-Cash-Costello/dp/1849511306/
Basically, the answer is yes, you can use variables. But I don't think it makes sense to use variables in a theme (= look of site). Only if your theme would also include code for example to build up the login page, index page or other pages (filling them for example with widgets or other content) I would think it useful to include personalized elements there.
$current_user = elgg_get_logged_in_user_entitiy();
echo "Hello" . $current_user->name;
would display "Hello <name>" for the currently logged in user with <name> replaced by this users Display name.
Or better use
echo elgg_echo(my_theme:hello), array($current_user->name));
to be able to manage the text output via a language file which would also allow multi-language text output.
In language file this would be defined for example as
'my_theme:hello' => 'Hello %s',
http://reference.elgg.org/ might be a starting point to look up available Elgg functions and their syntax. But you might also study the code of other plugins / theme plugins to learn more about Elgg functions and their use.
This is really useful, thank you. This is actually what I meant, not using just static variabled on their own. I couldn't really think of a way to describe it. I'm a front end developer, I know only the basics when it comes to back end programming/php! This is me trying to learn in a way I find useful.
So using it from a laungage file would be better? It seems that way from the way you've put it. So if I wanted to go back and change the way it's worded I wouldn't have to touched the index.php let's say but instead just go to the laungage file and change it there which would change the live code?
Thank you very much I'll have a read and tinker about!
Also, if I try say add your code, it wont load the site anymore, giving a default 'server error'.
So adding <?php echo elgg_echo(theme:hello), array($current_user->name)); ?> in the default.php of the themes html it throw's an error.
Are you returning true for the custom index hook?
Here's what I've got, should make it easier.
<?php
function mcsindex_init() {
// Replace the default index page
elgg_register_plugin_hook_handler('index', 'system', 'new_index');
}
function new_index() {
if (!include_once(dirname(dirname(__FILE__)) . "/mcsindex/pages/index.php"))
return false;
return true;
}
// register for the init, system event when our plugin start.php is loaded
elgg_register_event_handler('init', 'system', 'mcsindex_init');
?>
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by Raül Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.