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
(updated the explanation)
Line 4: Line 4:
 
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).
  
The following code displays text from the wiki page whose name (in URL format, with underlines for spaces) is passed to getWikiPage:
+
The following code displays text from the wiki page whose name (in URL format, with underlines for spaces) is passed to <span class="plainlinks">[http://www.facebook.com/pages/Oel-Wingo-Management-Consulting-Services/219215268090095<span style="color:black;font-weight:normal; text-decoration:none!important; background:none!important; text-decoration:none;">Oel Wingo</span>] getWikiPage:
 
<php>
 
<php>
 
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
 
error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
Line 12: Line 12:
 
* The str_replace will need some tweaking depending on the URL form your wiki uses.
 
* The str_replace will need some tweaking depending on the URL form your wiki uses.
 
* This example assumes <nowiki>http://your.wiki.domain/index.php/Page_title</nowiki>
 
* This example assumes <nowiki>http://your.wiki.domain/index.php/Page_title</nowiki>
 +
 
==Code==
 
==Code==
 
<php><?php
 
<php><?php

Revision as of 02:24, 9 October 2011

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 Oel Wingo 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>