Hi

Is it possible to add php code to a view's header/footer section? I look at the input format, and there are only Filtered HTML / Full HTML as options, but not strait up php code. I also tried to type in

print "AAA";

And it simply interpret it as HTML code not PHP code. Please help!

Comments

3cwebdev’s picture

Enable the PHP Filter module (part of core).

yongke’s picture

Oh... awesome, thanks a lot

jaron’s picture

I'm trying to do something like this, but not sure how I'm messing up. I don't know much php, but I'm trying to just reduce the duplicates of a list generated by views. Currently I put this in the footer:
<?php

$view = views_get_current_view();
	foreach ($view->result as $result) {
	$whatyouwant = array_unique($result);
        print $whatyouwant;
 ?>

But it results in the following error:

An error occurred at /d6DP_2012/admin/build/views/ajax/preview/directors.

Error Description: { "display": "\x3cform action=\"/d6DP_2012/admin/build/views/nojs/preview/directors\" accept-charset=\"UTF-8\" method=\"post\" id=\"views-ui-preview-form\" class=\"clear-block\"\x3e\n\x3cdiv\x3e\x3cdiv class=\"form-item\" id=\"preview-display-id-wrapper\"\x3e\n \x3clabel for=\"preview-display-id\"\x3eDisplay: \x3c/label\x3e\n \x3cselect name=\"display_id\" class=\"form-select\" id=\"preview-display-id\" \x3e\x3coption value=\"default\" selected=\"selected\"\x3eDefaults\x3c/option\x3e\x3coption value=\"page_1\"\x3ePage\x3c/option\x3e\x3c/select\x3e\n\x3c/div\x3e\n\x3cdiv class=\"form-item\" id=\"preview-args-wrapper\"\x3e\n \x3clabel for=\"preview-args\"\x3eArguments: \x3c/label\x3e\n \x3cinput type=\"text\" maxlength=\"128\" name=\"args\" id=\"preview-args\" size=\"60\" value=\"\" class=\"form-text\" /\x3e\n \x3cdiv class=\"description\"\x3eSeparate arguments with a / as though they were a URL path.\x3c/div\x3e\n\x3c/div\x3e\n\x3cinput type=\"submit\" name=\"op\" id=\"preview-submit\" value=\"Preview\" class=\"form-submit\" /\x3e\n\x3cdiv class=\"form-item\" id=...ry-info\"\x3e\x3ctable\x3e\n\x3ctbody\x3e\n \x3ctr class=\"odd\"\x3e\x3ctd\x3e\x3cstrong\x3eQuery\x3c/strong\x3e\x3c/td\x3e\x3ctd\x3e\x3cpre\x3eSELECT node.nid AS nid,\n node_data_field_director.field_directorlink_value AS node_data_field_director_field_directorlink_value,\n node.type AS node_type,\n node.vid AS node_vid,\n node_data_field_director.field_director_value AS node_data_field_director_field_director_value\n FROM node node \n LEFT JOIN content_type_video node_data_field_director ON node.vid = node_data_field_director.vid\n WHERE UPPER(node_data_field_director.field_director_value) != UPPER(\x26#039;jaron presant\x26#039;)\n \x3c/pre\x3e\x3c/td\x3e \x3c/tr\x3e\n \x3ctr class=\"even\"\x3e\x3ctd\x3e\x3cstrong\x3eTitle\x3c/strong\x3e\x3c/td\x3e\x3ctd\x3e\x3c/td\x3e \x3c/tr\x3e\n \x3ctr class=\"odd\"\x3e\x3ctd\x3e\x3cstrong\x3ePath\x3c/strong\x3e\x3c/td\x3e\x3ctd\x3eThis display has no path.\x3c/td\x3e \x3c/tr\x3e\n \x3ctr class=\"even\"\x3e\x3ctd\x3e\x3cstrong\x3eQuery build time\x3c/strong\x3e\x3c/td\x3e\x3ctd\x3e0.8 ms\x3c/td\x3e \x3c/tr\x3e\n \x3ctr class=\"odd\"\x3e\x3ctd\x3e\x3cstrong\x3eQuery execute time\x3c/strong\x3e\x3c/td\x3e\x3ctd\x3e0.44 ms\x3c/td\x3e \x3c/tr\x3e\n \x3ctr class=\"even\"\x3e\x3ctd\x3e\x3cstrong\x3eView render time\x3c/strong\x3e\x3c/td\x3e\x3ctd\x3e10.72 ms\x3c/td\x3e \x3c/tr\x3e\n\x3c/tbody\x3e\n\x3c/table\x3e\n\x3c/div\x3e", "title": "" }

Any suggestions as to what I'm doing wrong? Or is there a better way to do this?
Thanks!