Difference between revisions of "MediaWiki/archive/embedding/old/extract.php/v1"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
m (Woozle moved page MediaWiki/embedding/old/extract.php/v1 to MediaWiki/archive/embedding/old/extract.php/v1 without leaving a redirect: obsolete, keeps changing)
 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==Note==
+
==About==
This version is '''obsolete'''. Use only if newer code fails and you are looking for ideas. This was formerly "the slightly less-elegant method", and actually was created ''before'' the "[[../old1|old1]]" code (I'll swap them around later). --[[User:Woozle|Woozle]] 19:11, 6 June 2009 (EDT)
+
This version is '''obsolete'''. Use only if newer code fails and you are looking for ideas. This was formerly "the slightly less-elegant method", and was used with a MediaWiki version somewhere around 1.7 --[[User:Woozle|Woozle]] 19:11, 6 June 2009 (EDT) (updated 2011-03-12)
 
==Instructions==
 
==Instructions==
 
Create the file '''extract.php''' from the code below, and place it in your MediaWiki root folder (i.e. the folder where the main wiki's index.php is).
 
Create the file '''extract.php''' from the code below, and place it in your MediaWiki root folder (i.e. the folder where the main wiki's index.php is).

Latest revision as of 00:08, 15 December 2017

About

This version is obsolete. Use only if newer code fails and you are looking for ideas. This was formerly "the slightly less-elegant method", and was used with a MediaWiki version somewhere around 1.7 --Woozle 19:11, 6 June 2009 (EDT) (updated 2011-03-12)

Instructions

Create the file extract.php from the code below, and place it in your MediaWiki root folder (i.e. the folder where the main wiki's index.php is).

The following code displays text from the wiki page whose name (in URL format, with underlines for spaces) is passed to getWikiPage: <php> error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING); require_once('../wiki.sluggysquad.com/extract.php'); echo str_replace("/index.php/","http://your.wiki's.base.url/",getWikiPage('WWW_Wiki_Intro')); </php>

  • The str_replace will need some tweaking depending on the URL form your wiki uses.
  • This example assumes http://your.wiki.domain/index.php/Page_title

Code

<php><?php

// Adapted from extract2.php.html by Aero for use with SluggySquad site // Cleaned up slightly for htyp.org by Woozle

$pathtowiki = '/path/to/main/MediaWiki/folder';

header("Content-Type: text/html; charset=utf-8"); define( "MEDIAWIKI", true ); require_once($pathtowiki."/includes/Defines.php" ); require_once($pathtowiki."/LocalSettings.php"); require_once($pathtowiki."/includes/Setup.php");

function getWikiPage($pageName) {

 global $wgRequest,$wgOut;
 $useportal = $wgRequest->getText( 'title', $pageName );
 $wgTitle = Title::newFromText( $useportal );
 $wgArticle = new Article( $wgTitle );
 $mainText = $wgOut->parse( $wgArticle->getContent( false ) );
 return $mainText;

}

?></php>