Project:Persistent URL
Version:6.x-1.0-beta13
Component:Code
Category:feature request
Priority:normal
Assigned:EclipseGc
Status:needs review
Issue tags:purl

Issue Summary

OK, so this is the beginning of a views integration, this one is only working for spaces_og, however the method is extensible to any purl provider.

In the case of spaces_og we want to join the id field against nid. in other cases we might want to join to uid. Typically we can't do this in a single table, so instead of defining the purl table itself, I defined a mirror purl_spaces_og table and pointed it at purl. Joined id to nid, and provided a filter against the provider field to be used in conjunction with any other handlers that sets the where provider = 'spaces_og' in code. All of these handlers are SUPER straight forward and should be able to be re-used with a rename and changing the provider.

In addition to this I provided a default argument pluging that looks up the associated value of the purl_active() object. This could easily be copied and done for id as well, but it seemed moot.

Hopefully this is useful to others.

AttachmentSize
purl_views.patch4.58 KB

Comments

#2

Version:6.x-1.0-beta11» 6.x-1.0-beta13

still applies in beta13 - with a slight offset.

Haven't exhaustively tested, but - using this now - so far so good!

#3

I am trying this. it is useful to keep items in context

I rewrite another field
the replacement value of the purl field is "[value]".

In the following, the value of purl should be "development" instead it is "%3Cp%3Edevelopment%3C/p%3E%20". All other tokens work fine.

<a href="/[value]/node/[nid]">Click here</a>

I see in the patch that filter format default is used. Where is that defined? On my machine the default format is "Markdown"
'format' => FILTER_FORMAT_DEFAULT,

#4

subscribe

#5

whew, lifesaver.

tutorial for embedding group content/taxonomy using arguments:
under Arguments select "Purl > Purl: Value" then select "Provide default argument >Active Persiste URL Value (spaces_og)"

#6

I needed to use PURL as a views arguments with views 3 and drupal 7. Here is a simple solution in case anyone needs to do the same. This "workaround" is so simple that I don't think it's the best way.

To make this work I'm simply using a global variable defined in the purl provider callback.

<?php
function mymodule_purl_provider() {
  return array(
   
'mymodule_provider' => array(
     
'name' => t('Example provider'),
     
'description' => t('Some description'),
     
'callback' => '_mymodule_purl_callback',
    ),
  );
}

function
mymodule_purl_modifiers() {
  return array(
   
'mymodule_provider' => array(
      array(
'value' => 'section1', 'id' => "section1"),
      array(
'value' => 'section2', 'id' => "section2"),
    ),
  );
}

function
_mymodule_purl_callback($type) {
  global
$mymodule_section;
 
$mymodule_section = $type;
}
?>

Then, in you view add the contextual filter you want. Select "Provide default value" with a "PHP code" type. Here something like this should be enough (without the php open/end tags):

<?php
global $mymodule_section;
if (
$mymodule_section == "section1") {
  return
1;
}
return
0;
?>
nobody click here