[pmwiki-users] Disable ? on page link markup

Martin Fick fick at fgm.com
Wed Sep 28 12:23:17 CDT 2005


On Wed, Sep 28, 2005 at 11:55:06AM -0500, Patrick R. Michaud wrote:
> On Wed, Sep 28, 2005 at 12:29:31PM -0400, Martin Fick wrote:
> > One reason to want to disable the '?' supersrcipt on
> > certain non-existing pages is so that you can create a group which
> > only has a GroupFooter or GroupHeader in it (GroupB).  This
> > group would then be used to link to from another group's
> > pages (GroupA) using the 
> > 
> > GroupB.{$Name} 
> > 
> > markup expecting the GroupFooter or GroupHeader in GroupB to do
> > something with the name of the page.  So evne though this
> > page would render properly (as is done with Categories), the
> > link to this page would show up with the '?' superscript.
> 
> In other words, you're wanting PmWiki to somehow magically know
> that links to non-existent pages in GroupB should be displayed
> without the question mark, while links to non-existent pages in
> other groups should display the question mark?

Well, I was not expecting pmwiki to 'know' which groups. ;)

I was looking for something that a user could use when
creating the link itself, similar to what you did below,
but without requiring skins/CSS to change.

  But since you mention it, in this particular case, having
a group that can be set to not display the '?' without
author intervention would be helpfull, so I cooked up this
hack:


:--- pmwiki.php  (revision 1186)
+++ pmwiki.php  (working copy)
@@ -886,7 +886,8 @@

 function LinkPage($pagename,$imap,$path,$title,$txt,$fmt=NULL) {
   global $QueryFragPattern,$LinkPageExistsFmt,$LinkPageSelfFmt,
-    $LinkPageCreateSpaceFmt,$LinkPageCreateFmt,$FmtV,$LinkTargets;
+    $LinkPageCreateSpaceFmt,$LinkPageCreateFmt,$FmtV,$LinkTargets,
+    $LinkPageCreateGroups;
   if (!$fmt && $path{0} == '#') {
     $path = preg_replace("/[^-.:\\w]/", '', $path);
     return "<a href='#$path'>$txt</a>";
@@ -897,7 +898,14 @@
   $qf = str_replace('&amp;', '&', @$match[2]);
   @$LinkTargets[$tgtname]++;
   if (!$fmt) {
-    if (PageExists($tgtname))
+    # ~MRF Modified for Group disabling of ? markup
+    $cr = ! PageExists($tgtname);
+    if ($cr) {
+      $grp = FmtPageName("\$Group", $tgtname);
+      if (isset($LinkPageCreateGroups[$grp]))
+        $cr = $LinkPageCreateGroups[$grp];
+    }
+    if (! $cr) # ~MRF  Modified for Group disabling of ? markup
       $fmt = ($tgtname==$pagename && $qf=='') ?  $LinkPageSelfFmt
         : $LinkPageExistsFmt;
     elseif (preg_match('/\\s/',$txt)) $fmt=$LinkPageCreateSpaceFmt;


This allows an admin to define a group in config.php like this:

$LinkPageCreateGroups["AllInOne"] = FALSE;

which will not have '?'s displayed.

(AllInOne being the group with only a GroupFooter in it).



> Sounds really complex to administer and to be able to explain to
> folks ("links to non-existent pages appear with a question mark
> except when they're to pages in the ABC, GHI, or XYZ groups...").  

Agreed, a little complex for general use, works for me in
this case.



> Why not something more straightforward, such as...?
> 
>     OtherGroup.NonExistentPage
>     %noquest% GroupB.NonExistentPage
> 
> Here, %noquest% is being used to suppress the '?' of the second 
> link.  The CSS to make this happen is
> 
>     .noquest a.createlink { display:none; }
> 
> as demonstrated at http://www.pmwiki.org/wiki/Test/NoQuest .

This is nice, but for the case of non-existant group
homepages in pagelists it would be nice to do this without
CSS mods. Something similar to 

   %noquest% GroupB.NonExistentPage

but maybe more like

   GroupB.NonExistentPage^?
or
   GroupB.NonExistentPage(?)


-Martin





More information about the pmwiki-users mailing list