Hi all:
Does Drupal have an easier framework for views? I want to be able to do something fairly straight forward -- just as the front page of a Drupal installation can show all content (promoted to front page, or as a sticky), I want to have a view where I show all content of a particular group (using Organic Groups, og.module) on the group home page (doesn't matter what URL, as long as I can link to it).
So OG has functions for displaying the groups home page as well as a "generic" page (og_list_generic and og_view). For the groups home page, it's currently a table display and doesn't fit with the rest of Drupal and the clean display of nodes. I want to redefine this, so in my PHPtemplate template.php file, I redefined it by using most code from blog.module that shows the latest blogs (which is pretty much close to what I'm trying to do):
function phptemplate_og_list_generic($gid, $type, $mode) {
global $user;
$output = '';
$sql = og_get_home_nodes_sql($type);
$result = pager_query(db_rewrite_sql($sql), $num, $i, NULL, $gid);
while ($node = db_fetch_object($result)) {
$output .= node_view(node_load(array('nid' => $node->nid)), 1);
}
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url('blog/feed'));
drupal_add_link(array('rel' => 'alternate',
'type' => 'application/rss+xml',
'title' => t('RSS - blogs'),
'href' => url("blog/feed")));
print theme('page', $output);
}
This code is repeating the page outline over and over with no content, though the XML feed does show the correct content in there.
Am I taking the right approach? Does Drupal have a better way to create custom views (show nodes of this type, under this group), or does each module need to call the view itself, or...?
I am theming our application, and I'm really just trying to cleanly show all content for a group on their home page, or, say, just polls for the group on a separate link, etc.
Any direction is very much appreciated. Thank you!
--Dave
Comments
Did you figure anything out?
Did you figure anything out here? I am in the exact same boat. Where did this table come from? It used to be like a taxonomy page which was better for my needs.
I really don't want all my posts grouped into a table by type. I'd much rather have them all together in a list newest on top with the option of displaying the title and full body, or just title and teaser.
-zach
: z
Not yet
Haven't found the solution just yet -- getting back into it today.
I'll go on #drupal to see if Moshe Weitzman himself can give a bit more guidance.
[As I see it, there needs to be a concept for views; an easy way to take any type of content (with criteria as well; e.g. all polls for a particular OG) and choose a view for it, maybe more on the theme/non-programmatic level.]
--D
Let me know if you find
Let me know if you find anything - I'm trying to do this as well!
Per Moshe Weitzman
Per Moshe Weitzman, the module's creator, the way to do this would be to theme/re-define the theme_og_view function, and do some work with node_view and node_access to redefine the group home page.
So, using the PHPtemplate engine, in the templates.php file, you'd have a function called phptemplate_og_view.
Moshe says the query his module already makes available will work, i.e. $sql = og_get_home_nodes_sql($type);
I had already begun doing this, but my limited abilities with the Drupal APIs are inhibiting me. Can others pitch in and see if we can get the answer to this?
(Again, I really think Drupal is in dire need of a better philosophy / architecture for defining content and views. Perhaps the CCK is it...)
--Dave
Just to add, I have the
Just to add, I have the following code now, which is absolutely not working, but thought I'd post my direction.
So here's where I'm at:
So here's where I'm at: I've redefined the theme_og_view() function as phptemplate_og_view() in my templates.php file.
This is what I've got, including some debug output:
The value of $sql is:
SELECT DISTINCT(n.nid), n.title, n.uid, u.name, n.created, l.comment_count, l.last_comment_timestamp FROM {node} n INNER JOIN {node_access} og_na ON n.nid = og_na.nid INNER JOIN {node_comment_statistics} l ON n.nid = l.nid INNER JOIN {users} u ON n.uid = u.uid WHERE og_na.gid = %d AND og_na.realm = 'og_group' AND n.status=1 AND n.type NOT IN ('og', 'image') ORDER BY n.sticky DESC, l.last_comment_timestamp DESCThe value of the $result returned from the query is:
Resource id #58The value of $output is nothing, blank, nada.
I definitely have one piece of content under the group who's home page I'm looking at. Is it an issue with node_view()/node_load() or...?
Any insight from anyone?
--Dave
just my 2 cents
you may find helpful to look at previous og code in cvs, I think Moshe changed the displaying of a group home page around og v 1.70 (CVS version) or may be a little before 1.65 ? The previous one was like drupal home page so may be this old code could help you (IMHO the new displaying model is far easier to read ;-). regards. eric.
I think the ideal solution,
I think the ideal solution, for me at least, is to have both. In other words, I would like the ability to have the most recent (x) nodes presented, along with a complete (or partial)index.
-zach
harkey design
: z
Status
On and off with this, but I really have to begin making some progress.
Here's where I'm at. This code rethemes the group home page to show all nodes under the group (itself a node) in good old node_view style.
Great, but now I want other views: I want to be able to show all nodes of a particular type for the group at its own URL. In the OG.module, the default group home page separates out the different nodes in a table with pagination for each section, but it seems to me this was done in lieu of a what would have been a more complex system for showing them on different pages. I want to build that system -- I want a page with all the nodes (done above), a page with just blogs, a page with just polls, and ideally any combination of them.
Do I theme the og_list_generic function, or set up some new menu callbacks/functions in OG.module? Or is this something I should create my own views.module for, which creates a sort of container/parent node type called a View which can accept a set of criteria to pull children into it? Or...?
Any help from the Drupal community is much appreciated. This is my primary objective right now, and I want to make good use of my time. Asisstance would really ensure our team is using our time wisely and creating something the broader community can use. Think of us as Google Summer of Code people in need of a mentor(s). :)
--Dave
I think the above might have
I think the above might have been specific to drupal 4.7, so when I couldn't get that to work I went about it in what is probably not the best way, but a way that works all the same. I put up a page here: http://drupal.org/node/293906
I am not too sure, but Jake
I think Jake Gordon's module could give you what you are looking for: http://drupal.org/node/22902#comment-43774
Unforutnately, the beta site he mentions in the thread is not functional, but I remember that it looked good.
group home page description
Hi, im wonder how to show description of group
on top of group page?
i ask og creator but his reply yhat this is drupal theming issue
please help me!