I'm looking for any Elgg function similar to this WordPress function:
<?php is_home(); ?>
I need to check for the homepage like this:
<?php if (is_home()) {
But I don't know how.
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.
You could use
But it depends on what exactly you want to achieve to say it this makes sense / is necessary (or even works). For example the bundled custom_index plugin makes use of the "front" context but other themes (replacing the index page) might not.
Context 'front' don't work for me. I'm using this code:
if(((elgg_get_context() == 'activity') && elgg_is_logged_in() == FALSE) || ( (elgg_get_context() == 'front') && elgg_is_logged_in() == FALSE)) {
header( 'location: /login' );
}
I'm using RiverAdon and HypeAlive
I often use elgg_get_context() to print the context if I want to find out what context I'm at.
It's done!!!!!!!!!!!!!
Solution:
$url = "http://" . $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$homepage = elgg_get_site_url();
if ($url == $homepage) {
}
There's a difference between elgg_get_context() and elgg_in_context(). If elgg_in_context works for you is another question.
You can also set the context of any page using
Then if statement
My homepage is using "main" context, but (elgg_get_context() == 'main') don't work for me. I don't know why.
You need to put elgg_set_context() inside the page handler function.
Context can changes during page load, like when a widget is loaded the context switches to widgets. The only place to determine the starting context (in this case main) of a page is in the <head> section of the page.
Extending the head with elgg_extend_view() could be used for this and then use elgg_get_context().
A function to determine the start context in a normal view or widget would be nice though.
- Previous
- 1
- 2
- Next
You must log in to post replies.