Extension talk:RandomPages
Bug #1
editHello, I installed your extension, and found quickly a bug (well, not really a bug, but something to be modified) :
Line 71 of RandomPages.php :
$sql = 'select * from page where';
The table "page" might not exist, depending on the installation table prefix, set at the time of initial configuration. For exemple, my table corresponding to "page" was in fact called "wm_page".
I edited the source code and now it works fine! :-) Here are the modifications (line 71 and 72) :
global $wgDBprefix;
$sql = sprintf('select * from %spage where',$wgDBprefix);
--Fish1203 13:02, 9 February 2008 (UTC)
Thanks for the heads-up, it's fixed now in 0.2. You can drop bugs/feature requests at http://www.locknet.ro/contact, development it's done on http://gitorious.org/projects/randompages
Wiki text output
editHi, how can I change the output so I can enter wiki text in the extension, e.g. {{SomeTemplate|%s}}? --Subfader 15:58, 6 November 2008 (UTC)
Any way to transclude a single random page using this extension?
editI tried to modify this extension in a way that it only returns one article title without the A HREF stuff, hoping I could transclude a random page content like this:
{{:<randompages limit="10" namespace="true" levels="10" />}}
But this simply outputs a text string like
{{:Random page title}}
, not transcluding its contents. Are there any plans to enhance this extension to become a RandomPageContent extension? --Ulf Dunkel (talk) 17:36, 11 January 2021 (UTC)
- I now have adjusted the source file RandomPagesHooks.php in a way that limit=1 only returns the pure title name. Transcluding the output of my template in any article like "{{:{{RandomArticle}}}}" only creates a pure text string, not the expected transcluded page content. You can check this here on my wiki: https://en.intactiwiki.org/wiki/Template:RandomArticle
- What am I doing wrong? -- Ulf Dunkel (talk) 14:28, 7 March 2022 (UTC)
I've been searching for precisely that for a several weeks now (only on spare time, not 24/24 ^-^), to no avail. I want to transclude a random page section in the Hoshikaze 2250 project's wiki's welcome page. The ultimate achievement could be to take them from a special category where we could list all pages properly edited for transclusion. --Mutos (talk) 05:25, 12 July 2022 (UTC)
- Made the same adjustment as Ulf :
- if ($limit=1) {
- foreach ( $rs as $row ) {
- $title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
- $buff = htmlspecialchars( $title->getPrefixedText() );
- }
- } else {
- [original code]
- }
- Just printing the result Mutos (talk) 06:10, 12 July 2022 (UTC)
- There was also an extra div returned that I had to take out. But that was not the point... Mutos (talk) 06:14, 12 July 2022 (UTC)
- Would seem the text returned by the extension tag is not parsed as wikitext but just output as is. It may not be an issue with the extension itself, but with how one can force the parser to treat the returned text as wikitext... The core issue could be : how is the text returned by a tag parsed ? Mutos (talk) 07:01, 12 July 2022 (UTC)
- This page provides more insight, some parts could be outdated, but the general idea is that tag results are not further parsed : Manual:Tag extensions : "A simple tag extension consists of a callback function, which is hooked to the parser so that, when the parser runs, it will find and replace all instances of a specific tag, calling the corresponding callback function to render the actual HTML."
- I interpret this in the following sense for rendering my code :
- {{:<randompages namespace="true" limit="1" />}}
- First, the parser renders "{{:", then the sequence is interrupted by a tag. It invokes the tag, inserts the returned HTML, then renders the "}}" string, not noticing it closes the ""{{" sequence, as it was interrupted by the tag... Mutos (talk) 07:17, 12 July 2022 (UTC)
- Yeeees ! Found a way to do this by outputting the full transclusion code and forcing the parser to play on it :
$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
$buff = "{{:" . htmlspecialchars( $title->getPrefixedText() ) . "}}";
$title = Title::makeTitleSafe( $row->page_namespace, $row->page_title );
$buff = $parser->recursiveTagParse( $buff );
- This should be the object of another, specialized extension... Mutos (talk) 07:57, 12 July 2022 (UTC)
- Sorry, code includes an extra $title= line, just ignore it... Mutos (talk) 07:58, 12 July 2022 (UTC)