×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    Template talk:Fnord: Difference between revisions

    Content added Content deleted
    imported>mutante
    mNo edit summary
     
    imported>Took
    m (Reverted edit of 200.195.184.18, changed back to last version by mutante)
     
    (5 intermediate revisions by 2 users not shown)
    Line 11: Line 11:
    </pre>
    </pre>


    === Made fnord.sql import file ===
    ==== Made fnord.sql import file ====


    Using [[UltraEdit]] Macros i added '''insert into fnord.fnord (text) values ("''' to the start and '''");''' to the end of every line from [http://is-root.de/~mutante/fnord.txt this file].
    Using [[UltraEdit]] Macros i added '''insert into fnord.fnord (text) values ("''' to the start and '''");''' to the end of every line from [http://is-root.de/~mutante/fnord.txt this file].


    === Imported into wikidb.fnord ===
    ==== Imported into wikidb.fnord ====


    <pre>
    <pre>
    Line 21: Line 21:
    </pre>
    </pre>


    === Made Fnord Mediawiki extension ===
    ==== Made Fnord Mediawiki extension ====


    <pre>
    <pre>
    Line 68: Line 68:
    put this into /var/www/wiki/extensions/ as FnordExtension.php
    put this into /var/www/wiki/extensions/ as FnordExtension.php


    === Included extension in LocalSettings ===
    ==== Included extension in LocalSettings ====


    Added '''include("extensions/FnordExtension.php");''' to the end of /var/www/wiki/LocalSettings.php'''
    Added '''include("extensions/FnordExtension.php");''' to the end of /var/www/wiki/LocalSettings.php'''




    === Result - Random Fnords ===
    <nowiki><fnord></nowiki> =

    <nowiki><fnord></nowiki> =

    <fnord>

    </fnord>


    [[Category:Mediawiki Extensions]]

    Latest revision as of 23:12, 18 March 2006

    How this works[edit]

    Created mysql table[edit]

    CREATE TABLE `fnord` (
      `id` int(11) NOT NULL auto_increment,
      `text` varchar(255) default NULL,
      PRIMARY KEY  (`id`)
    ) TYPE=MyISAM;
    

    Made fnord.sql import file[edit]

    Using UltraEdit Macros i added insert into fnord.fnord (text) values (" to the start and "); to the end of every line from this file.

    Imported into wikidb.fnord[edit]

    mysql -u root -p wikidb < fnord.sql
    

    Made Fnord Mediawiki extension[edit]

    <?php
    #  Fnord Mediawiki extension
    # display random fnord definitions in wiki pages using a <fnord> tag
    # inside a {{Template:Fnord}}
    # input can be used for LIMITing the mysql random select (later)
    # by mutante 17.04.2005
    
    $wgExtensionFunctions[] = "wfFnordExtension";
    
    function wfFnordExtension() {
    global $wgParser;
    $wgParser->setHook( "fnord", "renderFnord" );
    }
    
    function renderFnord( $input ) {
    
    $input = mysql_escape_string($input);
    
    # check if input is integer else set to 1
    if (is_int($input)){
    $limit = $input;
    } else {
    $limit = 1;
    }
    
    $hd = mysql_connect("localhost", "wikiuser", "PASSWORD") or die ("Unable to connect");
    mysql_select_db ("wikidb", $hd) or die ("Unable to select database");
    $res = mysql_query("SELECT * from fnord ORDER BY rand() LIMIT 0,$limit", $hd) or die ("Unable to run query");
    while ($row = mysql_fetch_assoc($res))
    {
    $id = $row["id"];
    $fnord = $row["text"];
    }
    $output = " $fnord ((K)fnord_id #$id))";
    
    return $output;
    
    }
    
    ?>
    

    put this into /var/www/wiki/extensions/ as FnordExtension.php

    Included extension in LocalSettings[edit]

    Added include("extensions/FnordExtension.php"); to the end of /var/www/wiki/LocalSettings.php


    Result - Random Fnords[edit]

    <fnord> =

    <fnord>

    </fnord>

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.