By andrew_hoffi on
I've been fighting with this problem for the last few hours, so i'm hoping the community may be able to help.
I'm setting a variable from the results of db_query in my page.tpl.php file based on the path and a few other conditions, but I really want to know how to pass that data through to the views module via arguments.
How can I access the value from the variable?
I have tried this in page.tpl.php
global $myVariable;
$myVariable = X
and this in the PHP default argument
global $myVariable;
return $myvariable;
Any help would be appreciated!
Comments
Not sure what this has to do
Not sure what this has to do with page.tpl.php, normally you would make a page display for the view, give it a path (url) and "call" it by adding any arguments. So it the path was say 'something' and the view expected a nid you would use a path like something/213
Totally and that's how I
Totally and that's how I would do it, however I'm adjusting the theme, colour etc... by running checks on page.tpl.php these alterations are stored in organic group nodes. So in the page.tpl.php file I have the ID of the group, which I want to pass through to the view.
Sure I could just pass the ID of the node via the url, but this would look messy and I would rather keep the group name, which I'm then checking on page.tpl.php that its a group, correct language etc and then trying to pass that back to the view in order to filter the records for the specific group.
That's where my problem lies, unless anyone has any other ideas
I have tried using the full call within the default php argument, but this does not work I'm assuming as I'm unable to run db_query() in side argument php????
Thanks
Andrew
-------------------
www.hoffi.com
I suspect you are doing
I suspect you are doing things in page.tpl.php that should be done either in a module or hook_preprocess_page().
If the only goal is to filter to the specific group without using an argument the filter "Organic groups: OG: Posts in current group" sounds like it will meet your needs.
Your probably correct about
Your probably correct about using hooks or a module and I understand your thoughts about adding the filter, but....
The view I'm creating is a calendar of events, normally I would pass an argument in the path something like group/%/events (group/189/events)
but... what if I want to use the group name E.g. group/group_name/events
So based on the url I query the database in page.tpl.php for the group node based on the group_name then I have the $nid value to pass into the view, but how do I do this? Here's my query, which I have error checking around btw
So from this I want to pass $AssociatedProject->nid through to the view and use it as an argument.
Thanks
Andrew
-------------------
www.hoffi.com