Hi there,
I can't find the right for me.. Hope someone can help me.
I have a view "myview" with 2 fields - "title" and "nid".

Now I want to get the "nid" into the header of the current view ("myview"). Can someone help me to solve this..
PHP of Header...

$view = views_get_current_view();

GET VALUE? OF the field nid!! But how??

print "My NID is"; print ?NID? ;

Cheers Kai

Comments

okmi’s picture

i also need to do something like this. what would the syntax look like for outputting a field in the view's header or footer using php?

cflemm’s picture

I would love to know this as well!

dawehner’s picture

Category: task » support

i added

<?php
$view = views_get_current_view();
dsm($view->result);
?>

IN $view->result you can access the different results of the view.

andrenoronha’s picture

i'm trying to print the numbers of reads

print $view->result[0]->node_counter_totalcount . ' reads.';

but this 0 stands for my first result... how can I call the generic variable for each result?

p.s: I'm not using the node statistic field directly because I just want to show the reads for the author of the node. so I'm using a php customfield to print it.

merlinofchaos’s picture

Status: Active » Fixed

If you're using a php custom field, I would think there should be a $row variable available in the customfield. But I'm not sure, since that's not a module that I am familiar with. I know if you're theming the field, you can look at $row to see the raw data of the field.

I have to say, the initial post really failed to provide enough context. It really matters where you're doing this stuff to see how you access the information.

andrenoronha’s picture

thanks for your reply.
in fact it was easier than i thought. I just called $data which brings the data in the fields of the view.

print $data->node_counter_totalcount . ' reads.';

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.