Extension:BedellPenDragon

The BedellPenDragon extension is like a combination of Extension:Random In Category and the example page_props metadata extension, with glossary, essay, miscellany, quote and video list special pages added on. The extension makes available a  tag and parser functions to allow pages to add or remove metadata to/from the page_props table. It is designed to be used in conjunction with Extension:CategoryGallery and Extension:RecentPages, if you want additional functionality. Perhaps the best way to explain it is by example. All of these features you can see either displayed or available from the PolyWiki main page.
 * Articles:
 * Transclude Template:FASummary to add themselves to Category:Featured articles, from which are chosen the Randomly featured article.
 * Transclude Template:InvisiblePageSummary to add entries to:
 * Special:Glossary.
 * Recently added articles.


 * Essays:
 * Transclude Template:FESummary to add themselves to Category:Featured essays, from which are chosen the Randomly featured essay.
 * Transclude Template:InvisiblePageSummary to add entries to:
 * Special:EssayList.
 * Recently added essays.


 * Quotes:
 * Transclude Template:FQSummary to add themselves to Category:Featured quotes, from which are chosen the Randomly featured quote.
 * Transclude Template:InvisiblePageSummary to add entries to:
 * Special:QuoteList.
 * Recently added quotes.

Examples of how this is done: This data can be queried by sites external to your wiki using the API. Also, you can create sidebars similar to RationalWiki's Template:Sex that display a random list of x articles in a given category. So, for example, an article on fractional reserve banking could have a sidebar with a list of 12 randomly selected banking articles. This way, users who revisit the article will be exposed to new content each time.
 * Article example (view source)
 * Essay example (view source)
 * Quote example (view source)

Another advantage is that vandals and spammers almost certainly won't know to use the templates that will cause content to be seen on the main page and on other pages that use the data. There's other stuff that could be done with this extension too, such as creating "Did you know?" tidbits of information for display on the main page; it would be easy to add another special page to display a master list of those items. In case anyone was curious, this extension was named after w:User:JPatrickBedell and Vlad Draconis PenDragon (aka Matthew Mercer-Kinser).

Creating more special pages
By default, this extension implements a Glossary, an EssayList, a QuoteList, a MiscellanyList, and a VideoList. You don't need to create more special pages if you don't want them, but here's how to do it if you're so inclined. Let's say you want to create a Special:ReasonList. Create : Now put in LocalSettings.php:

$wgBedellPenDragonGlossaryIntros
The page that will be transcluded into the beginning of the special page out.

$wgBedellPenDragonGlossaryTitlePropnames
The property names for the page titles.

$wgBedellPenDragonGlossarySummaryPropnames
The property names for the summaries.

$wgBedellPenDragonGlossaryWikifyTitles
Wikify the titles that are displayed in the special page?

$wgBedellPenDragonGlossaryStripFromFront
Strip this (usually a colon-suffixed namespace) from the front of displayed page titles.

$wgBedellPenDragonGlossaryReplace
Do a search and replace on this. It's in the form of an array.

$wgBedellPenDragonGlossaryAuthor
Is this special page a two-level hierarchy of author (top-level) and title (bottom-level)?

Usage
The most obvious uses of this extension are as follows:

Random page in category
To get the page title of a random page in Category:Aubry, use, e.g.: 

Or to get a bulleted, wikified, sorted list of 12 random page titles from Category:Nathan Larson essays:

]] *[[

Load that into a wikipedia:Template:Sidebar like this (although ideally you'll find a way to make the page titles wrap if they get too long, rather than making the sidebar expand to fit them on one line apiece; please improve upon this example if you can):

It'll give you something like this:



Or to get the content of a randomly-chosen page from Category:Featured quotes with s 1 and 26 excluded:



Parameters
The input, i.e. the text between the opening and closing tags, overrides the delimiter parameter.

Today's featured article
After importing the templates mentioned above, and adjusting your Template:Today's featured article to exclude the appropriate page IDs (they'll be different on your wiki than what they are on PolyWiki), start your featured article (e.g. polyamory) like this:



Transclude Template:Randomly featured article to your main page and you'll get something like this:



"New Pages" or "Did You Know" descriptions via metadata from the pages themselves (requires RecentPages extension)
You'll need Extension:RecentPages for this.

PageSummary template and New Pages display of pages with that template
Write your wiki pages like this:



Notice how this creates two summaries separated by a pipe; the short summary is the first sentence, while the long summary is the first sentence followed by the rest of the summary. You can then use the Recent Pages extension to create something like this, which you'll put in, e.g. Template:New articles at PolyWiki‎: 

This will produce a result like this, when inserted into the appropriate main page template (e.g. one you can borrow from Main page):



(See Extension:RecentPages for an explanation of the  tag parameters used above.)

You can create wikitext like this, that uses a different page summary than what you put for the article lead. E.g., in this case it was necessary because the article lead had wikified words in the page title:
 * The distinction between polyamory and swinging is that at the core, polyamory is about multiple, consensual, sexual, loving relationships while swinging is multiple, consensual, sexual relationships.

List of new unsummarized articles
Template:New articles without summaries will give you a result like this:



CategoryGallery with captions generated from image description files (requires CategoryGallery extension)
You'll need Extension:CategoryGallery for this. Place image descriptions on your image file pages (e.g. File:Popsicle stick Eiffel Tower.jpg) using the same PageSummary template as before. Now, on the page where you're putting the gallery, use e.g.:



The result is as follows (note how the captions are generated using the metadata you saved on each image page):



When I use in a nested table I get a bunch of repeating nested tables.
Yeah, the problem there is that the pages that are transcluding the category are being included in the pool of pages from which one is randomly selected. When one of those transcluding pages gets picked, you end up with those repeating nested tables. There are two possible solutions, the first of which is probably superior.
 * 1) Put in the template that adds your data to the page_props table something like to prevent it from adding adding templates and the main page to the category.
 * 2) Find out the page IDs of those transcluding pages and then use the "exclude" parameter. E.g., exclude="1,26" if you're trying to exclude pages 1 and 26. It's an awkward solution and it'll mess up if, for instance, you delete one of those pages and undelete it, giving it a new page ID. See Extension:BedellPenDragon.

The main page or templates are appearing in Special:Glossary, Special:EssayList, Special:MiscellanyList, Special:QuoteList or Special:VideoList.
You need to add to the template that's transcluded to the main page or the templates, to exclude the main page and templates from being added to the glossary, essay list, or quote list.

These templates aren't categorizing anything properly and as a result nothing is being picked by .
This issue sometimes comes up when you have a template on the page (e.g. Template:FESummary, the template that adds pages to Category:Featured essays) that only puts it in the category if the page is in a certain namespace (e.g. the Essay: namespace). The purpose of this is to avoid putting the Template:FESummary page in the category If this is the situation, did you remember to create the namespace using $wgExtraNamespaces? E.g. if it's a featured essay, did you create an Essay: namespace or did you accidentally create your essay in mainspace?

This stuff is not behaving the way I'd expect.
When in doubt, purge your caches.

I deleted a page and now it's showing up in these "new x" RecentPages feeds. How do I get rid of it?
This is tricky. A workaround would be to do some sort of SQL query to find out what item in page_props has a pp_page that doesn't match up with any page.page_id, and then delete that row from page_props. But I don't know how to construct that query.

FAQ
===I want to have a random article or an excerpt thereof (if it's a long article) display on the main page, sort of like wikipedia:Wikipedia:Today's featured article. Is this the right extension to use?=== It depends on exactly what you're trying to accomplish:
 * Do you want to have any article on the wiki, regardless of quality, be eligible to appear on the main page, with the only standard being (perhaps) that it's of a certain minimum length? E.g., do you have such a large selection of articles you want to be eligible to be displayed as featured articles that it would be impracticable to maintain a centralized list or to add them as members of a Category:Featured articles? Then Extension:Blurb might be the extension you want.
 * Do you have a pretty short list of articles that you want to have be eligible to appear on the main page, and you don't mind editing a page containing a centralized list every time you want to add or remove articles from the list? Then Extension:RandomSelection might be the one you want. See http://wiki.mises.org/wiki/Template:Featured_article for an example of RandomSelection in action.
 * Do you want to have articles be displayed as featured articles if and only if those articles are members of, say, Category:Featured articles? Then BedellPenDragon is the extension you want.

With reference to, why does the "exclude" parameter have users specify page IDs rather than page titles, and why isn't there a "namespace" parameter?
Developer laziness, and also the fact that does not have the necessary fields to make it as simple a matter as just adding another condition to a SELECT database query. This extension was mostly designed for small wikis with only a few users, at most, who would need to know how to use that tag. Make good use of the PAGEID magic word to find out page IDs, if you need to. Then of course there's the API; see e.g. https://www.mediawiki.org/w/api.php?action=query&prop=pageprops&titles=Extension:BedellPenDragon. In the long run, page metadata features, perhaps involving Wikidata, are supposed to be developed that are better and more scalable.

Should this extension be rewritten to use a Summary: or Metadata: namespace instead of the page_props table?
It's an interesting idea (and Extension:ExplicitDescription does something like that), but then you'd need to make more than one edit, to more than one page, if you're changing both the page content and the page metadata. This isn't unheard of; for example, when you move a page, you already often have to make more than one change (i.e. (1) actually moving the page and (2) changing the page content to reflect the new title).

The fact that there might be other metadata besides just the page summary suggests that you might want to call it a Metadata: namespace. However, RationalWiki does have a Summary: namespace, mostly for discussion threads.

===Unlike Extension:Advanced Meta, this extension doesn't have a separate description inputbox in the edit screen, but rather it uses description templates that are part of the page contents. Nor does it have a separate ext_meta table; instead, you clog up the page_props table. Why is that?=== If you store the description stuff separately from the page content, then it complicates the process of importing it into another wiki, if you ever wanted to do that. It would be necessary to add new API functionality and/or modify the code implementing Special:Import and Special:Export. The way it is now, you can just transfer over the templates and page content and it works. I'm not saying that's the best solution, but any other solution would be more complicated and require further development.

This extension was mostly designed for small wikis, so it wasn't deemed necessary to create a new table. Certainly that might be a good idea if, say, this extension were to be used on Wikipedia, but I would hope WMF would come up with a more elegant metadata solution, since they've already decided to go the Wikidata route.

Why is there not a special page similar to Special:AllPages, except that it lets you list all the pages with their summaries or other metadata?
I've never been able to successfully do a JOIN in MediaWiki, except this one time when I hardcoded a raw SQL query into Extension:Chat (see the code that starts with ). If I could figure out how to do the necessary JOIN or UNION or whatever it is that's necessary to implement this, I would do that. I'm really not all that skilled with that intermediate SQL stuff. If you can come up with the query, and better yet, show me how to use the database wrappers to implement the query, then I'll get crackalackin on that right away. See 56604, by the way.

Should this extension be regarded as fixing bug 23016?
Sort of, but there are many possible ways to fix that bug, and it's not clear that this is the best way.

Why use this instead of Semantic MediaWiki?
Because SMW is buggy and its support website blows. SMW might be more powerful and easier to use, though, until you run into something that it's not capable of handling.

Why do I keep making typos when I type "bpdprop"?
It has a series of four very similar letters in a row. It's a finger-twister — like a tongue-twister, except that it plays out on your the keyboard. When the eye looks at it, it just sees a bunch of gobbledygook and doesn't realize when there's an error.

How do I call the glossary something else (e.g. "dictionary") and make the link Special:Dictionary instead of Special:Glossary?
Add this to LocalSettings.php:

Known issues

 * If you include an inline external link, it won't work properly for some reason.