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
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!
- An Article page with a non-existent Discussion page will show a Red Discussion Tab
- 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.
- 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.
* %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:)
* %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:)
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
* %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] ]]
(: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
(: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 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
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
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?).