Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the behaviour of datatable Tag links #3

Closed
einhirn opened this issue Jan 25, 2010 · 2 comments
Closed

Change the behaviour of datatable Tag links #3

einhirn opened this issue Jan 25, 2010 · 2 comments

Comments

@einhirn
Copy link
Contributor

einhirn commented Jan 25, 2010

I created a Patch that checks for the existance of a page called “Object” in the root namespace and in the current namespace. If it doesn't find anything, it checks whether <current_namespace>:start or <id_of_current_namespace> exists as a page and assumes a data table there.

--- data/helper.php     2009-02-13 15:26:25.000000000 +0100
+++ ./helper.php        2009-08-10 16:24:57.000000000 +0200
@@ -88,7 +88,7 @@
      * Return XHTML formated data, depending on type
      */
     function _formatData($key, $value, $type, &$R){
-        global $conf;
+        global $conf,$ID;
     $vals = explode("\n",$value);
     $outs = array();
     foreach($vals as $val){
@@ -120,7 +120,16 @@
             $outs[] = '<a href="'.hsc($val).'" class="urlextern" title="'.hsc($val).'">'.hsc($val).'</a>';
             break;
         case 'tag':
-                    $outs[] = '<a href="'.wl(str_replace('/',':',cleanID($key)),array('dataflt'=>$key.':'.$val )).
+                   $key_id=str_replace('/',':',cleanID($key));
+                   if(page_exists($key_id)) {
+                   } elseif (page_exists(getNS($ID).':'.$key_id)){
+                       $key_id=getNS($ID).':'.$key_id;
+                   } elseif (page_exists(getNS($ID).':'.$conf['start'])){
+                       $key_id=getNS($ID).':'.$conf['start'];
+                   } elseif (page_exists(getNS($ID))){
+                       $key_id=getNS($ID);

Maybe there is a more elegant solution to this problem, perhaps via config option or an option in the datatable syntax. I think that I saw such an option for the Tagcloud syntax...

@einhirn
Copy link
Contributor Author

einhirn commented May 10, 2010

Together with current advancements in Datatable plugin (Type aliases) and this patch, there is a possibility to configure a type alias for "tag" that produces links in a definable namespace:

diff -u admin.php.orig admin.php
--- admin.php.orig  2010-04-28 07:29:00.000000000 +0200
+++ admin.php  2010-05-10 14:03:32.000000000 +0200
@@ -82,7 +82,7 @@

         $form->addElement('<td>');
         $form->addElement(form_makeMenuField('d['.$cur.'][type]',
-                                array('','page','title','mail','url', 'dt'),$row['type'],''));
+                                array('','tag','page','title','mail','url', 'dt'),$row['type'],''));
         $form->addElement('</td>');

         $form->addElement('<td>');
diff -u helper.php.orig helper.php
--- helper.php.orig  2010-04-28 07:29:00.000000000 +0200
+++ helper.php  2010-05-10 14:22:29.000000000 +0200
@@ -118,8 +118,14 @@
             $outs[] = '<a href="'.hsc($val).'" class="urlextern" title="'.hsc($val).'">'.hsc($val).'</a>';
             break;
         case 'tag':
-                    #FIXME handle pre/postfix
-                    $outs[] = '<a href="'.wl(str_replace('/',':',cleanID($column['key'])),array('dataflt'=>$column['key'].':'.$val )).
+                   #FIXME handle pre/postfix sensibly
+                    if(substr($column['prefix'],-1)==':') {
+                       $page=$column['prefix'].$column['key'].$column['postfix'];
+                   } else {
+                       $page=$column['prefix'];
+                   }
+
+                   $outs[] = '<a href="'.wl(str_replace('/',':',cleanID($page)),array('dataflt'=>$column['key'].'='.$val )).
                   '" title="'.sprintf($this->getLang('tagfilter'),hsc($val)).
                   '" class="wikilink1">'.hsc($val).'</a>';
             break;

The patch is a hack of the "works for me"-kind - maybe there is a more sensible approach to using "prefix" and "postfix" than what I coded. This code tests if the last character of "prefix" is the namespace divider. If so, it concatenates prefix, column-name and postfix to form the link target. Otherwise it just links to prefix.

@Klap-in
Copy link
Collaborator

Klap-in commented Oct 23, 2012

Changing the target of tags can be done by using the alias feature of the data plugin.

Go to 'Admin' page and in the list below to 'Data Plugin: Field Aliases'
On the empthy line you fills:

  • Type alias: Name for new type e.g. newtag
  • Type: select tag
  • Data Prefix: url of the page that contains the datatable which is filtered by this tag when clicked
  • Data Postfix: keep empty
  • Valid values: keep empty

Save aliases

Now you can use it in a dataentry, e.g.:

---- dataentry projects ----
type            : web development
task_newtags    : programming, coding, design, html
job_newtag      : full time
----

See also https://www.dokuwiki.org/plugin:data#change_tag_target_with_a_tag_type

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants