Page MenuHomePhabricator

New Variable __NEWSECTIONS__ like __TOC__
Closed, ResolvedPublic

Description

Author: mediazilla

Description:
This is about the feature to add new comments to a page. By default they are added to the end of the
discussion-article (or article, however). But what, for example, if you want to install a little message at the end of
your discussion page? if than a section is added that little message wont be still at the end of the page. So it would
be great to have a Variable like TOC that can be used to determine WHERE new sections will be added. If that
variable is ommited the default behaviour will of course be executed.


Version: unspecified
Severity: enhancement

Details

Reference
bz6793

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:21 PM
bzimport set Reference to bz6793.
bzimport added a subscriber: Unknown Object (MLST).

achuggard wrote:

This would be pretty neat... I could fosee 2 magic words NEWSECTIONABOVE and
NEWSECTIONBELOW which would of course put the new section above or below the
marker (first marker taking precidence). With NEWSECTIONBELOW, it would enable
discussions to flow the opposite way (with the newest sections floating to the
top and older discussions sinking to the bottom of the page.

mediazilla wrote:

Just to understand you right: Are you speaking of something like that:

<page>Hello, this is my discussion page, you can [[%editlink%|leave me a message]].
(generated toc or with TOC placed)
NEWSECTIONBELOW
(new sections will go here)

discussion

blablabla

discussion

blablabla</page>

<page>Still my discussionpage
(TOC)

discussion

blabla
:answer

discussion

blabla
(new sections will go here)
NEWSECTIONSABOVE</page>

The second example is the default behaviour, except there would be standing something after NEWSECTIONSABOVE

i guess i more needed to make that clear to myself with an example ;) good idea either ^^

alexsm333 wrote:

Any chance NEWSECTIONBELOW could be implemented? It will be really useful for some forums that flow bottom-to-top.

Right now "Add new subject" link is implemented with &action=edit&section=0 but this way the top "{{/header}}" part gets accidentially deleted from time to time.

  • Bug 21141 has been marked as a duplicate of this bug. ***

Nx.devnull wrote:

Add PlaceNewSection hook to allow extensions to override placement of new sections

[[mediawikiwiki:Extension:PlaceNewSection]] can do this, but requires a patch to WikiPage.php (Article.php in MW1.17 and older); I had to introduce a new hook because none of the existing ones were suitable.

Attached:

Nx.devnull wrote:

Oops, that interwiki link didn't work, here's the full url:
http://www.mediawiki.org/wiki/Extension:PlaceNewSection

(In reply to comment #5)

Created attachment 9275 [details]
Add PlaceNewSection hook to allow extensions to override placement of new
sections

[[mediawikiwiki:Extension:PlaceNewSection]] can do this, but requires a patch
to WikiPage.php (Article.php in MW1.17 and older); I had to introduce a new
hook because none of the existing ones were suitable.

Attached:

(In reply to comment #6)

Oops, that interwiki link didn't work,

Clicking it WORKSFORME.

Could you also provide a patch for hooks.txt? http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/docs/hooks.txt?view=markup

Nx.devnull wrote:

I swear it didn't work... someone must've turned on forwarding.

Anyway, do you think it would be a good idea to change the parameters, or is it okay like this? Right now it's a bit illogical IMHO, $oldtext is the text of the page before the edit, $text is the text of the new section (i.e. the contents of the edit box), and the hook expects you to put the new, merged text into $text, since that's how the core code works; but it would make more sense to have a &$text that contains the old text, a $subject and a $sectiontext, and then you'd have to replace $text with the merged version. That would make more sense since you're changing the page text, not the text of the new section, but would require some additional code to put everything where it's supposed to go before and after calling the hook.

Nx.devnull wrote:

hooks.txt documentation for the PlaceNewSection hook

Attached:

(In reply to comment #8)

Anyway, do you think it would be a good idea to change the parameters, or is it
okay like this?
[...] the hook expects you to put the new, merged text
into $text, since that's how the core code works;

Making your hook work like the core is better, imo.