CommentPageLink-Talk

Showing a 'Live' or 'Dead' Discussion Tab similar to Wikipedia

  • To have the discussion tab appear RED or dead if no discussion page exists, and BLUE or live when a discussion page exists, modify the Discussion line in Site.PageActions as follows:
(:if exists Comments.{$Group}-{$Name} :)
* %item class=discuss accesskey=$[ak_edit]%[[Comments.{$Group}-{$Name}?action=view | $[Discussion] ]] 
(:else:)
* %item red class=discuss accesskey=$[ak_edit]%[[Comments.{$Group}-{$Name}?action=view | $[Discussion] ]] 
(:ifend:)
  • To ensure the Discussion tab on the Comment page also appears RED or dead until the page is actually created, modify the Discussion line in Comments.PageAction as follows:
(:if exists Comments.{$Group}-{$Name} :)
* %item class=browse accesskey=$[ak_view]%[[{$FullName} | $[Discussion] ]] 
(:else:)
* %item red class=browse accesskey=$[ak_view]%[[{$FullName} | $[Discussion] ]] 
(:ifend:)

The above tested with pmwiki-2.2.0-beta42. Des April 10, 2007, at 09:28 PM

The above works almost for me. The exception is if no Discussion Page for a certain page exists yet. Than I get the message "This page doesn't exist". What can I do to make the pageactions create an Discussion page (instead of trying to show one) if there is no Discussion Page yet? - Torsten May 27, 2007, at 01:10 PM
Option of Autocreation of pages only exists for Categories as far as I know. It would be potentially messy for Discussion, as it would mean that a page would be created even if someone only looked to see if there was any Discussion content (ignoring or unaware that red means there is no current Discussion content). This would then create an empty/blank Discussion page for the Subject page, whether or not they made a comment, negating the Live/Dead colour coding too, since the existence of the blank page would render the tab Blue. Des May 30, 2007, at 04:54 PM
Thanks Des for your answer. So does that mean, users can see that a discussion doesn't exist (tab red) but they can't create a discussion page if it doesn't exist already? I didn't know that the Autocreation of pages was restricted except for categories. I will just have a look into that, maybe I can find out something to make the discussion (tab) work the way I want it (autocreate a blank discussion.articleXYZ if there is no discussion page for articleXYZ tab yet).
P.S. I had a look at your wiki http://www.secretscotland.org.uk and http://www.butewiki.de-soft.co.uk/ (the linkdescription of the latter on your user site contains a field.php too much in the end) and find your solution of letting users create discussion pages pretty clever. I'm a pretty Wiki Newbie, so is there any chance you tell me how you made those nonexistent discussion pages where users can create a real discussion page with one click? Cheers Torsten June 08, 2007, at 06:21 AM
Sorry for delay, and thanks for the warning about the old link note (forgot all about the early trials).
I should confess there was an error in the password setting for the PageActions I had set up using the above, I never saw the error as Admin, but users that were not logged in got Discussion pages that didn't work properly!! As of June 11, 2007, the Discussion on my sites should work properly... for everybody!
  1. An Article page with a non-existent Discussion page will show a Red Discussion Tab
  2. Clicking on the Red Discussion Tab takes the user to the normal warning page that says the page they've asked for does not exist, and offers the usual option to click a link that will create the page. They can click that to create the Discussion page, or just click the Article tab to go back to the page they just came from, if they decide not to start a discussion.
  3. An Article page that has an existing Discussion page will show a Blue Discussion Tab, and clicking this just takes the user to the existing discussion page, as expected.
You can very easily modify the behaviour of the above to open the Discussion on a BLANK page, ready for editing (rather than the page creation mode), by substituting the view action for the edit action in (:else:) line that sets the red colour in Site.PageAction as follows:
* %item class=discuss accesskey=$[ak_edit]%[[Comments.{$Group}-{$Name}?action=view | $[Discussion] ]] 
(:else:)
* %item red class=discuss accesskey=$[ak_edit]%[[Comments.{$Group}-{$Name}?action=view | $[Discussion] ]]    <<-- change view to edit
(:ifend:)
Changes to:
* %item class=discuss accesskey=$[ak_edit]%[[Comments.{$Group}-{$Name}?action=view | $[Discussion] ]] 
(:else:)
* %item red class=discuss accesskey=$[ak_edit]%[[Comments.{$Group}-{$Name}?action=edit | $[Discussion] ]] 
(:ifend:)
In this case, even though a blank Discussion page is presented to the user, it is still non-existent, and is only created if they actually hit Save. If they just leave the page, then it is not created or saves, so doesn't mess with the Red non-existent signal.
Now that I've seen both options, I don't know which I thinks is less confusing or intimidating to new users. Oh well. Des June 11, 2007, at 05:06 PM
Hi Des, many thanks for your detailed explanation. Inspite of your wonderful advice here, the Discussion-Tabs in my wiki are behaving strangely. My Site.PageActions looks like the following:
* %item class=browse accesskey=$[ak_view]%[[{$FullName} | $[Document] ]] (:if exists Discussion.{$Group}-{$Name}:) 
* %item class=discuss accesskey=$[ak_edit]%[[Discussion.{$Group}-{$Name}?action=view | $[Discussion] ]] (:else:)
* %item red class=discuss accesskey=$[ak_edit]%[[Discussion.{$Group}-{$Name}?action=edit | $[Discussion] ]] (:ifend:)
* %item white class=edit accesskey=$[ak_edit]%[[{$FullName}?action=edit | $[Edit] ]] 
* %item rel=nofollow white class=diff      accesskey='$[ak_history]'%[[{*$FullName}?action=diff | $[History] ]]
    (:if auth upload:) 
* %item white class=upload accesskey=$[ak_attach]%[[{$FullName}?action=upload | $[Attach] ]] 
    (:if:) 
* %item white class=print accesskey=$[ak_print]%[[{$FullName}?action=print | $[Print] ]]
Strange enough if I view this site ([(approve links) edit diff]) there is no discussion tab, whereas there is a black AND a red one (which work they way they should) separated by a (:else:) on the Mainpage of the wiki ([(approve links) edit diff]). On some pages in the group Main (e.g. [(approve links) edit diff]) there is also no discussion tab but on others (e.g. [(approve links) edit diff]) independent from if there is a discussion page or not existing. In other groups (e.g. in the group Articles [(approve links) edit diff]) there seem to be both tabs at the same time as well. Any idea where the mistake could be? - Torsten June 20, 2007, at 04:12 PM

Hi Torsten
I haven't looked in detail, but if the content you have copied is EXACTLY as it appears on your own Site.PageActions page, then it won't work!

The lines MUST appear EXACTLY as shown in the recipe above, and not be reformatted as they appear to be in your page.

The reason for this is that each line is an Action or Conditional markup, and has to be processed individually. Running the lines together, and removing the markups that begin with (: from the start of the line means they are not interpreted as Actions or Conditional controls, hence no tabs appear (because of the spurious characters now added to the ends of the lines defining the PageActions).

Try re-formatting all the lines EXACTLY as they are given in the recipe, and see if things improve. Don't forget, this needs to be done for the Comments.PageActions page too. Let us know how it goes. Des June 23, 2007, at 08:42 PM

Hi Des, many thanks for your help. I've corrected the Site.Pageactions according to your hints. But unfortunatelly I haven't been able to make a substantial difference with this. The two Discuss-tabs are now on two lines and the (:else:) is on a line between them (on the rendered page). I suspected the extendmarkup.php (which I activated in order to have footnotes) to cause the troubles and switched it off in the config.php. The footnotes were gone but the above described Discuss-tab behaviour not. Torsten June 24, 2007, at 02:33 PM

I had to ditch extendmarkup.php for the same reason, problems with other recipes!

I just checked your wiki installation, and you are running a very old version, 2.1.27, not even 2.2, (current is 2.2.0-beta57) and much has changed, including the way pages are referenced inside markup. This recipe depends on some of the recent changes, so you will have to upgrade your installation or this particular Discussion tab recipe will never work. (You didn't mention correcting Comments.PageActions above, so I'm mentioning it, just in case). So I suggest upgrading, check Site and Comments PageActions are ok, and there's not much left to go wrong. Des June 24, 2007, at 06:34 PM

Hi Des, again thanks a lot for your advice. I did the upgrade to pmwiki-2.2.0-beta57, corrected the Comments.PageActions and yes there is now only one Discussion-Tab in the menu and the @[(:else:)]@ has vanished from the rendered page as well. I think Comments.PageActions and the Site.PageActions are the way they are supposed to be.
But now the whole menu (the Site.PageActions) refers only to the Site.PageActions. Like when I click "Print" on the main site or any other site than I can only print out the rendered Site.PageActions (the menu itself) or when I click "Discussion" than I can have a discussion only about Site.PageActions. Same with the "View" and "Edit"-tab, which let's me view and edit only Site.PageActions. Looks like I have forgotten something fundamentally important, but I can't come up with what it might be. Any idea? (the page is at [(approve links) edit diff]) Torsten June 26, 2007, at 12:20 PM

Hi Torsten, great that you were able to do the upgrade etc. Now that the markup is working "as expected" I can see what has gone wrong now.

My fault as I didn't remember the original recipe (not mine) wasn't updated for the later PmWiki, and I had forgotten about the changes I had needed to make to get it to work again (sorry).

As this discussion has grown, I will move it to the when I post the corrected code later, and then update this page with the revised code once you any further bugs are cleared once you have it working.

Since seeing your site, I should warn you that the original was written for monobook skin (which I use) and I don't know if that may be a source of further problems. I only understand part of how this skin works! Des June 26, 2007, at 06:56 PM

Hello Des, thanky for having a further look at my problem. Best wishes, Torsten June 27, 2007, at 03:24 AM

Hi Torsten. I think I have cleaned all the bugs/errors/typos out of the two PageActions, and it seems to do as required on my site. I also now use the Discussion group rather than Comments. Surprised it was working at all once I found all the rubbish that was scattered inside it from earlier tweaking. As I noted, this uses the monobook skin, which has additional php coding, so I don't know if it will work on an ordinary skin. You can try it on my site fist, where the NastPage page currently has no Discussion, to see how it works before and after starting one http://www.secretscotland.org.uk/index.php/Secrets/NastPage This is just a test page, so is not important in any way, and is deleted often. Des June 27, 2007, at 10:34 AM


Developed for Monobook Skin? (and phrased to be similar to Wikipedia) from the earlier recipe above, the following PageAction markups provide a Discussion tab that displays in Red until a Discussion page is created, and Blue one the Discussion page has been created.

Also, when on the Discussion page, the Article tab will return the user to the original article, and the Discussion tab will either be inactive when the page is being viewed (preventing recursive discussions of discussion), or active when the page is being edited, when it will cancel the edit and return the user to the original Discussion.

NOTE

The following page contents are currently missing the leading * from the group and page names. They don't seem to me needed with monobook skin, but are on others. I need to check this before posting this back to the main recipe page.

1 Modify config.php

Add this markup by C.Gruber to config.php to perform the replacement for the backward link to the article

Markup("@3@", "inline", "/@3@(.*?)@3@/e", 'str_replace("-",".","$1")');

2 Modify Site.PageActions

This is my site.PageActions markup, which can be used as is, or edited to reveal the required page actions and tab text

* %item class=browse accesskey=$[ak_view]%[[{$FullName} | $[Article] ]] 
(:if exists Discussion.{$Group}-{$Name} :)
* %item class=discuss accesskey=$[ak_edit]%[[Discussion.{$Group}-{$Name}?action=view | $[Discussion] ]] 
(:else:)
* %item red class=discuss accesskey=$[ak_edit]%[[Discussion.{$Group}-{$Name}?action=edit | $[Discussion] ]] 
(:ifend:)
* %item class=edit accesskey=$[ak_edit]%[[{$FullName}?action=edit | $[Edit this page] ]] 
* %item class=diff accesskey=$[ak_history]%[[{$FullName}?action=diff | $[History] ]] 
(:if auth upload:) 
* %item class=upload accesskey=$[ak_attach]%[[{$FullName}?action=upload | $[Attach] ]] 
(:ifend:)
(:if false:)
* %item class=print accesskey=$[ak_print]%[[{$FullName}?action=print | $[Print] ]]
(:ifend:)

3 Create Discussion.PageActions to provide the action tabs on the Discussion page

This is my Discussion.PageActions markup, which can be used as is, or edited to reveal the required page actions and tab text

* %item class=back accesskey=$[ak_back]%[[@3@{$Name}@3@?action=view | $[Article] ]]
(:if exists {$Name}:)
* %item class=browse accesskey=$[ak_view]%[[{$FullName} | $[Discussion] ]] 
(:else:)
* %item red class=browse accesskey=$[ak_view]%[[{$FullName} | $[Discussion] ]] 
(:ifend:)
* %item class=edit accesskey=$[ak_edit]%[[{$FullName}?action=edit | $[Edit this page] ]] 
* %item class=diff accesskey=$[ak_history]%[[{$FullName}?action=diff | $[History] ]] 
(:if auth upload:) 
* %item class=upload accesskey=$[ak_attach]%[[{$FullName}?action=upload | $[Attach] ]] 
(:ifend:) 
(:if false:)
* %item class=print accesskey=$[ak_print]%[[{$FullName}?action=print | $[Print] ]]
(:ifend:)

The above tested using pmwiki-2.2.0-beta57.


He Des! It works! THANKS A LOT! I had to add an asterisk to all {$Name} {$FullName} and {$Group}-{$Name} just before the $ so that I got now {*$Name} {*$FullName} and {*$Group}-{*$Name}. Otherwise the whole menu would have only been valid for the Site.PageAction (as I described above). But now it works, I don't know why. Or I don't know why it works without the asterisks in your wiki, cause I just had a look at the PageActions-Draft to see the usual PageActions and there I saw all the asterisks (and no I'm not drunk ;). Anyway the important thing is it works. So thank you for your great help. Without you I would have never managed this. Cheers and best wishes to Scotland from Saxony, Torsten June 27, 2007, at 02:58 PM

Hi Torsten. (Very) Glad you found out about the asterisk *. That was one of the changes I had originally made to the original recipe to update it for use with the latest PmWiki release. While I was tweaking the recipe today, I found that the * was (apparently) not needed, as the page references worked correctly with or without it in place. It SHOULD be needed, but when it worked ok (on my site) I assumed my understanding of its function was in error, so didn't include it. It tells PmWiki to use the group/page it's actually on, or the group/page it came from as the source, so mine (with no * ) really shouldn't be working at all!
I'll have to have another debug session before posting this back on the main page later, just to see why mine works (since it shouldn't). If I can't find a reason, I'll just have to add the leading * anyway, but I'd rather know why. Maybe it's a side effect of the additional php code used in the monobook skin (just a guess, I did say I hadn't worked out quite what it does). Thanks for the feedback Des June 27, 2007, at 03:28 PM
Just to let you know that I have tried the Discussion recipe with both monobook skin and standard PmWiki skin, and confirmed that one of the side-effects of the additional php code in monobook means the leading asterisk on the various page variable is indeed not needed. Switching to the standard skin breaks breaks the recipe if the asterisks are not included, as I had originally expected, but didn't suffer from as the extra php obviously provided similar functionality. Now that I've proven the recipe with the asterisks in place, I'll make some time later to update the main page properly. Nearly done. Des June 27, 2007, at 09:31 PM

I am on PmWiki 2.2.0 beta59, with Monobook skin. I am using Wikiforms and the Formtitle recipe to create new pages. The page therefore has a numbered 'name' but the 'title' of the page becomes its name (for example, Projects.00001 becomes Project.Museum etc.) With the above directions, The disucssion link first creates Comments.Prooject-00001 page. Then, the backlink created is to Project.00001, which does not exist.
I did try and modify the PageList code for the Discussion link to point to Cookbook.{?title} instead, but then I have the same problem other way around, the Comments.Project-Museum tries to link back to Projects.Museum, which again does not exist. What modification should I make to correct this?? S. Kumar 25 July 2007.

Hi All

This is a great addon I was having problems and thought I was on the most recent release but wasnt. Once I changed it it worked like a charm

Thanks Des!!!


GAAAA!! I too have been chasing my tail with this for hours, happily under the impression I was running the latest version, but no I wasn't - have upgraded and all's well. THANKS DES!

I have a question though. I'm using Monobook. When I edit a page, the discussion tab also looks active, so it looks like I'm editing and discussing... I guess this is due to the discussion tab needing to have the edit action (I get 404 page not found if I use view). Any thoughts on how to get round this?

Talk page for the CommentPageLink recipe (users?).