I have created the function necessary for pathauto support.

 function og_vocab_pathauto_taxonomy($op, $category=NULL) {
  switch ($op) {
    case 'placeholders':
      $placeholders = array();
      $placeholders[t('[ogname]')] = t('The name of the organic group this category belongs to.');
      return $placeholders;
    case 'values':
      $results = array();
	  $results[t('[ogname]')] = '';
	  
	  $where = ' ov.vid = %d';
      $sql = "SELECT n.title FROM {node} n INNER JOIN {og_vocab} ov ON ov.nid = n.nid WHERE $where";
      $result = db_query($sql, $category->vid);
      while ($row = db_fetch_object($result)) {
		$name = $row->title;
        $results[t('[ogname]')] = pathauto_cleanstring($name);
      }
	  
      return $results;
    default:
      break;
  }
}

However, to get it to work with bulk updates this patch to fix a bug in pathauto is necessary: http://www.drupal.org/node/70456

CommentFileSizeAuthor
#8 og_pathauto.patch1.09 KBdavid lesieur

Comments

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

adam - i have granted you cvs access to this module. feel free to commit once you have some code you are comfortable with. if you want a 2nd opinion, ask for one in this issue tracker and i will try to review.

might as well just committ his one since we will fix any problems that are reported.

moshe weitzman’s picture

Status: Reviewed & tested by the community » Needs work

out of curiosity, why is this needed? if a node gets posted, pathauto already knows what og it belongs to and what terms were affiliated. is this just needed to make sure those stay consistent when multiple of each were picked?

moshe weitzman’s picture

also, t('[ogname]') looks real odd to me. do most pathauto modules translate this? if it is an id, it should not be translated. if it is human readable text, it should. i fear that it is both in pathauto?

moshe weitzman’s picture

Status: Needs work » Fixed

anyway, i am going to comnmit this ... still curious about answers to my questions.

cooperaj’s picture

Sorry about the delay in posting. Lost access for a week.

This code allows you to use your organic group name in Taxonomy vocab listings, this is what makes it different to the normal OG support of pathauto. It allows you to use the alias in the path for the taxonomy page. Like so:

Normal:
taxonomy/234

Pathauto (alias):
this/is/my/listing

This patch (with pathauto):
mygroup/this/is/my/listing

It just helps to further separate group vocabs from site-wide vocabs.

Just out of interest. I don't quite understand the access I have to this module. As far as I know I have commit access to contrib (though life got in the way of committing the module that gained me the right). How do I have access to this one?

moshe weitzman’s picture

thanks.

i just added you as a committer for thois project. you can now commit to it, using usual cvs commands ... please post an issue and wait for feedback before doing so.

Anonymous’s picture

Status: Fixed » Closed (fixed)
david lesieur’s picture

Version: master » 4.7.x-1.x-dev
Status: Closed (fixed) » Needs review
StatusFileSize
new1.09 KB

t('[ogname]') seems really strange to me too. But I just discovered that pathauto already does this for all its ids, so I guess we might want to keep it for consistency... Must be very problematic on multilingual sites though...

I don't understand why a loop and a query is necessary for generating the alias. Here's a patch that removes both.

The patch applies both to the 4.7 and 5 branches and should work on both, but I've tested only on 4.7.

david lesieur’s picture

Version: 4.7.x-1.x-dev » master
Status: Needs review » Closed (fixed)

Oops, just realized I'm in the wrong queue... I'll re-post in the right place. Sorry!