Print Mission on the Front Page
Hello,
Some people may like to know how to print the site_mission (as set in the site settings) to the front page of the theme. This will give you a message on the index page (like on drupal.org) that you can edit just by editing the site mission.
Here is the code:
<?php
//if we are looking at the index.php page with no QUERY_STRING then print the site_mission
if(substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"], "/") + 1)=="index.php" && !$_SERVER["QUERY_STRING"]) print variable_get("site_mission", "");
?>
Or you may want to print it in a box:
<?php
//if we are looking at the index.php page with no QUERY_STRING then print the site_mission
if(substr($_SERVER["PHP_SELF"], strrpos($_SERVER["PHP_SELF"], "/") + 1)=="index.php" && !$_SERVER["QUERY_STRING"]) print $this->box(variable_get("site_mission", ""));
?>

Print Mission
I cannot seem to get this to work. I took the code, added it into a new block, and set it to PHP. But get errors, do I need to put something infront of the PHP code in the Block?
----Martin----
Drupal blocks
For Drupal PHP blocks to work you have to
a) omit the php tags (<?php and ?>)
b) return the content.
For whatever reason, I just c
For whatever reason, I just cannot get it to work :-(
----Martin----
What theme are you using?
The code depends upon the theme.
I recently added this to the bluesky theme by adding this code to the header function (about line 180)
179 global $user;180 if (($user->uid == 0) && ($_GET["q"] == variable_get("site_frontpage ", "node"))) {
181 $this->template->assign("site_mission", variable_get("site_mission", "EDIT THE SITE MISSION"));
182 $this->template->parse("header.mission");
183 }
This assumes that there is a theme block called mission in the header block.
Drupal PHP Blocks
Does that allow you to include files? I'm getting the actual code that I'm trying to use instead of what I'm actually trying to do.
http://www.democracyforwashington.com/civicspace-0.5/?q=phptest
Is that what you mean by 'return the content'?
You can do anything that PHP
You can do anything that PHP allows you in the block code. Any output, however, needs to be collected in an output string and that string has to be returned:
<?phpinclude('myfile');
$output = call_some_function();
return $output;
?>
Hmm, still not working
I'm probably not familiar enough with PHP, but I tried a basic value assign and return, and it's just giving the code. When I add in the
<?phpand
?>
Sure, you have to select "PHP
Sure, you have to select "PHP" as the block's mode.
Yep, PHP
I double checked, and PHP is selected.
Here's the code I'm using:
<?php
$testval = "testing";
return $testval;
?>
I've tried it with and without the brackets. With gives no result at all, without gives:
$testval = "testing"; return $testval;
simpler (untested)
if(!arg(0)) {print variable_get("site_mission", "");
}
Doesn't seem to work
I tried this in 4.2 and it didn't seem to work. Always returned FALSE.
menu_get_active_item()
It's better to use menu_get_active_item() and compare it to variable_get('site_frontpage', 'node').
(though in CVS/4.5, menu_get_active_item() returns a menu ID rather than the path and you need more code to resolve it to a path)
Heres a front page module...
Here is a home page module for drupal:
http://mrphp.com.au/node/1654
Mr PHP :: We Create Codehttp://www.mrphp.com.au
How to print mission containing php code to front page
I've done it using PHPTemplate in Drupal 4.7 in page.tpl.php with code:
<?phpif (($mission)&&($is_front)) {print eval($mission); }
?>
Mission is set in administer/settings/general and contains php code without angle brackets returning a string.