Jump to content

Template:GuestbookWidget: Difference between revisions

From LovedForever
somepage>Prabal
Fix Add-a-Memory link: VE cannot open section=new in visual mode; switch to full-page veaction=edit (works for VE + preload on the first entry) and guard the transclusion with #ifexist so an empty Guestbook doesn't show a redlink
 
Detect /Stories by title text (main namespace has no subpages enabled on live)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{#ifexist:{{FULLPAGENAME}}/Guestbook
<div class="guestbook-form-widget" data-guestbook-subpage="{{FULLPAGENAME}}"></div>{{#ifeq:{{#titleparts:{{PAGENAME}}|1|-1}}|Stories|[[Category:Stories|{{#titleparts:{{PAGENAME}}|-1}}]]}}
|{{:{{FULLPAGENAME}}/Guestbook}}
|''Be the first to share a memory.''
}}
 
[{{fullurl:{{FULLPAGENAME}}/Guestbook|veaction=edit&preload=Template:Memory_Preload}} '''➕ Add a Memory''']
<noinclude>
<noinclude>
Drop <code><nowiki>{{GuestbookWidget}}</nowiki></code> into any memorial page's
Drop <code><nowiki>{{GuestbookWidget}}</nowiki></code> at the <strong>bottom</strong> of a
Guestbook section. It works on whichever page it's placed on — no page name to
memorial's own "PersonName/Stories" subpage, below any existing entries -- not the main
fill in — by transcluding "&lt;This page&gt;/Guestbook" and linking to a
memorial page. Visitors read the existing stories first, then find the form last. It
VisualEditor edit of that same subpage.
renders a native submission form (built by <code>MediaWiki:Common.js</code>) that posts
new entries onto *this* page as <code>{{Memory|...}}</code> entries, inserted directly
above this transclusion (not simply appended to the end of the page) so the form stays
pinned at the bottom as more entries are added -- since the existing entries on the page
are simply the rest of its wikitext, there is no separate storage subpage any more.


Important: do NOT pre-create the "PersonName/Guestbook" subpage. VisualEditor's
A "Stories" tab pointing at this subpage is added automatically to the parent
preload only fires for a page that doesn't exist yet — if the subpage already
memorial page (see the <code>SkinTemplateNavigation::Universal</code> hook in
exists (even blank), the first visitor loses the pre-filled form. The
<code>LocalSettings.php</code>) for every main-namespace page, as a redlink until
{{#ifexist:}} above shows a friendly placeholder instead of a redlink until
its "/Stories" subpage actually exists.
the first memory is saved.


The first memory on a page opens pre-filled via preload. After that, the page
Posting is open to anyone, logged in or not -- anonymous visitors can post
already has content, so VisualEditor can no longer preload it automatically —
text, but the photo-upload button is disabled for them (MediaWiki's default
later visitors use VisualEditor's Insert > Template > Memory dialog instead
permissions don't grant anonymous users the "upload" right).
(TemplateData gives it labeled fields and a real photo picker).
</noinclude>
</noinclude>

Latest revision as of 02:19, 24 October 2026

Drop {{GuestbookWidget}} at the bottom of a memorial's own "PersonName/Stories" subpage, below any existing entries -- not the main memorial page. Visitors read the existing stories first, then find the form last. It renders a native submission form (built by MediaWiki:Common.js) that posts

new entries onto *this* page as

A Visitor



entries, inserted directly above this transclusion (not simply appended to the end of the page) so the form stays pinned at the bottom as more entries are added -- since the existing entries on the page are simply the rest of its wikitext, there is no separate storage subpage any more.

A "Stories" tab pointing at this subpage is added automatically to the parent memorial page (see the SkinTemplateNavigation::Universal hook in LocalSettings.php) for every main-namespace page, as a redlink until its "/Stories" subpage actually exists.

Posting is open to anyone, logged in or not -- anonymous visitors can post text, but the photo-upload button is disabled for them (MediaWiki's default permissions don't grant anonymous users the "upload" right).