Bookmark Us
User login
Video Tags
Recent comments
- Slot nuts online casino
8 hours 36 min ago - Vegas slot online casino
2 days 7 hours ago - Buspar similarty to xanax
5 days 10 hours ago - Buspar drug
1 week 6 days ago - Tmd buspar
2 weeks 4 hours ago - Buspar ocd works
2 weeks 6 hours ago - dave
2 weeks 6 days ago - mate flick
3 weeks 13 hours ago - Osha safety training requirements
3 weeks 6 days ago - Automated telemarketing
4 weeks 1 day ago
Recent blog posts
- cck & taxonomy
- Dynamically execute all Drupal cron jobs for an entire server
- Creating a view to show all nodes that exist in user's Organic Groups using argument handling code in Drupal 6
- CCK select option html entity issue
- Create an admin settings page for your module
- user warning: Got a packet bigger than "max_allowed_packet" bytes
- Creating a multipage form using the Forms API
- Defined Variables Scope Tip
- Load a CCK node $form object using drupal_retrieve_form
- Restrict which roles can modify node taxonomy
Navigation
Creating a view to show all nodes that exist in user's Organic Groups using argument handling code in Drupal 6
I recently created a view to show all the nodes that exist in a user's organic groups. I originally created the same view in Drupal 5 by adding the filter "OG: Post in User Subbed Groups" is equal to "Currently Logged In User". Unfortunately, I could not find the equivalent filter in Drupal 6 Views, so I decided to use arguments. Argument handling code is structured a differently in Drupal 6:
1) add a new argument
2) for "Action to take if argument is not present" choose "Provide default argument"
3) for "Default argument type" choose "PHP Code"
4) for "PHP argument code" I entered:
return MYMODULE_views_group_nids();It's a personal preference of mine to NOT insert code into my database, so I added the previously called function into a module. IMHO, code belongs in subversion so it can be versioned properly, not in a database. Here's my function definition:
<?php
function MYMODULE_views_group_nids()
{
// create SQL statement to look up all group nodes of the current user
$sql = "select nid from og_uid where uid = '%d' and is_active='1'";
// query database
$resource = db_query($sql, db_escape_string($GLOBALS['user']->uid));
// fetch results from resource
$results = array();
while ($row = db_fetch_array($resource)) $results[] = $row['nid'];
// rollup results, comma separated
$results = implode(',', $results);
// return result
return $results;
}
?>No comments
Popular content
- WAMP + phpBB Forum Software (4,850)
- Install Free Message Board PHP Script (3,150)
- Add external Javascript and CSS on Friendster (... (662)
- PHP Tutorial : Making a comment system without... (593)
- User Signup Page using PHP and MySQL (541)
- Thing Thing 4 Trainer (516)
- Automatically generate meta keywords from a node... (473)
- PHP Tutorials : Login and Register : User... (416)
- Create Remember Me Login using PHP and Dreamweaver (374)
- Access and Modify User Profile using PHP and... (323)
- API GDATA (316)
- Affiliate Link Cloaking Using PHP Redirect (308)
- Basic CSS Tutorial (307)
- 1. Simple PHP Code and the WAMPserver (304)
- WAMP + phpBB Forum Software (280)
- Joomla! Tutorial - Email configuration for RSForm... (273)
- Oracle APEX Tutorial 3 - Creating a Drilldown... (264)
- Zend Framework tutorial 1 MVC basics (261)
- Dynamically resize image dimensions using jQuery (259)
- Create Dynamic Table using PHP and Dreamweaver (247)
- Create User Login using PHP and Dreamweaver (245)
- Flash CS3 AS3 Contact Form with PHP parser -... (239)
- Changing Link Color Using Dreamweaver (235)
- JForms (A WYSIWYG forms component for Joomla 1.5) (234)
- How to open all external links in a new window... (217)
- About Us (210)
- drupal fckeditor wysiwyg in 7 minutes (206)
- Flash WYSIWYG Open Code Rich Text Editor Tutorial... (203)
- PHP Tutorials: MySQL (Part 1) (195)
- Insert data Into Mysql Using PHP - Tutorial (193)
- Create Photo Gallery using PHP and Dreamweaver (190)
- How to make a maze game in Flash CS4 (188)
- PHP - MySQL - Flex 3 Client-Server Application (187)
- PHP-SYSLOG-NG webinstall (185)
- Progress Bar : ajax php (183)
- XAMPP - Make your Computer a Webserver: Apache,... (181)
- REC #94 Cascading Style Sheets level 2 CSS2... (179)
- Drupal Tutorial - Building A Yahoo Answers Clone (179)
- Create Master/Detail pages using PHP and... (177)
- Update- uCoz Site .... What about Webs (176)
- Drupal Tutorial - Breadcrumbs (176)
- PHP Tutorial 1 : Beginners Basics (175)
- Drupal Tutorial - Theming Search Results (175)
- DMC Tutorial - How To Make A Link In Same Page... (175)
- Using Kompozer The Best Free WYSIWYG Editor (174)
- PHP Screenshot Class Demostration (173)
- PHP MVC Introduction - FUSE Model View... (172)
- HTML Tutorial 1 (171)
- Drupal 6 Cache API Example / Tutorial (171)
- scripting tutorial -Css & Html 1_4 (170)
Search This Site
Tags in source
Today's popular content
- WAMP + phpBB Forum Software (4,441)
- Install Free Message Board PHP Script (2,899)
- Add external Javascript and CSS on Friendster (TUTORIAL) (535)
- PHP Tutorial : Making a comment system without SQL. (534)
- User Signup Page using PHP and MySQL (495)
- Thing Thing 4 Trainer (441)
- Automatically generate meta keywords from a node's taxonomy terms (413)
- Create Remember Me Login using PHP and Dreamweaver (324)
- API GDATA (289)
- Basic CSS Tutorial (243)
- PHP Tutorials : Login and Register : User Registration (MySQL) Part 2 (233)
- Affiliate Link Cloaking Using PHP Redirect (223)
- Access and Modify User Profile using PHP and Dreamweaver (219)
- WAMP + phpBB Forum Software (208)
- REC #94 Cascading Style Sheets level 2 CSS2 Specification (174)





















Add your comment