Hi all,
Hope you can help me a bit. I have two node types, Company and Division, Division has a node reference to Company. The view has exposed filters for Node Type=Company or Division, Division Title and Company.
Currently the view correctly returns all of the Divisions within a Company when you select a Company from the exposed filter, however, what i need to do is to modify the results so that i show the Company node that the view has been filtered on at the top of the results.
What I am having trouble with is knowing where to add the code to modify this result. So far i have been trying to insert this via template files without much success: I can see that the Company drop down filter has node id's in the #value that would allow me to do a node_load, but this seems to only be available in views-exposed-form.tpl.php and doesn't seem to allow me to output the node information before the rest of the view.
i.e. Select company B in exposed filter would result in:
Company B node Division of Company B node 1 Division of Company B node 2 Division of Company B node 3 Division of Company B node n
Where should i be looking to intercept the display of the view so that i can insert the company node at the top ? Should I be looking at hooks or template files ? I have already messed around with relationships, but that doesn't seem to be giving me the correct result that i require.
Any assistance would be greatly appreciated.
Regards, Nik
Nik Derewianka ha scritto:
What I am having trouble with is knowing where to add the code to modify this result. So far i have been trying to insert this via template files without much success: I can see that the Company drop down filter has node id's in the #value that would allow me to do a node_load, but this seems to only be available in views-exposed-form.tpl.php and doesn't seem to allow me to output the node information before the rest of the view.
Hi, You need to use hook_form_alter() to alter the view's form before it's rendered.
M.
On 16/06/2010, at 12:26 AM, Michel Morelli wrote:
Nik Derewianka ha scritto:
What I am having trouble with is knowing where to add the code to modify this result. So far i have been trying to insert this via template files without much success: I can see that the Company drop down filter has node id's in the #value that would allow me to do a node_load, but this seems to only be available in views-exposed-form.tpl.php and doesn't seem to allow me to output the node information before the rest of the view.
Hi, You need to use hook_form_alter() to alter the view's form before it's rendered.
Okay i seem to be making some progress, i have made my own module, hook_form_alter is being called, print_r() on $form and $form_state show me lots of tantalising information, but it doesn't show the currently selected value for the exposed filter dropdown - is this because I am using ajax for the form and it is therefore not showing up in the form_state ??
Also, just to test the output, i did a straight hardcoded node_load(..), by printing the node->body and understandably it prints the content out before the rest of the rendered page. I assume that i have to insert it into the output of the view somehow, would this be by modifying the $form variable and inserting the appropriate array information?
Am I on the right track here ?
Thanks, Nik