User talk:Barre/MediaWiki/Extensions/kw bread crumbs

From KitwarePublic
Jump to navigationJump to search

Hey thanks Sebastien for you help with the trail, however your positioning description was a little confusing.

So I have saved the file kwBreadCrumbs.php into extensions folder and and entered include("extensions/kwBreadCrumbs.php"); into LocalSettings.php.

I want the trail to run along the top of the page like in your Wiki system. I have set $on_top_hack = 1; What does "use the tag anywhere in the page " mean?

Thanks in advance, really neat little idea. Also just in case you were wondering my wiki will not be going public. Its just a research project for university.

Ali.


It seems this extension was written in mind for the 1.3 series. I got the "Anywhere in the layout" part working for the 1.4 series. You need to add:

<div><?php echo kwBreadCrumbsTAL() ?></div>

into: <wikibasedir>/skins/MonoBook.php

This of course will limit this option to monobook, but i'm sure you could add it to your other skins as well.

Laner 16:28, 25 Apr 2005 (EDT)



Has anyone gotten this to work for mediawiki 1.4rc1? I've spent some time to try to get this working but I keep getting "database error" and "internal error". there's no place on the net that talks about this, i've scoured every last webpage for a month already :(

Then I noticed that the version of this wiki:

   MediaWiki (http://wikipedia.sf.net/): 1.3.0beta4 
   PHP (http://www.php.net/): 4.3.8-9 (apache) 
   MySQL (http://www.mysql.com/): 4.0.20-log

while mine is:

   MediaWiki (http://wikipedia.sf.net/): 1.4rc1 
   PHP (http://www.php.net/): 4.3.9 (apache2handler) 
   MySQL (http://www.mysql.com/): 3.23.58

this has got to be the reason why it isnt working for me...

Jctong 18:22, 26 Apr 2005 (EDT)

You guys are right, I did not test this extension for 1.4 yet. I will try soon.


I updated this extension and the documentation so that it can work with MediaWiki 1.4. Sadly, the on_top_hack option that made it easy to put the trace on top of the page does not work with 1.4 anymore, so you will have (as one user noticed already) to directly call the extension from the template code. See doc. Hope this helps. Note that as of today, this web site is still running 1.3. It will be upgraded by our sysadmin to 1.4 soon, at which point the examples may not be working properly until I notice the upgrade ;)


It appears that you have not taken into account a database table prefix that may have been set by the user. This can be overcome by replacing line 429 in the kwBreadCrumbs.php file with the following:

Find:

$sql = "UPDATE cur SET cur_touched='$now' WHERE cur_namespace=$ns AND cur_title='$ti'";

Replace With:

if ( $options ) {
  $db =& wfGetDB( DB_MASTER );
} else {
  $db =& wfGetDB( DB_SLAVE );
}
$cur = $db->tableName( 'cur' );
$sql = "UPDATE $cur SET cur_touched='$now' WHERE cur_namespace=$ns AND cur_title='$ti'";

Xangelusx 13:10, 1 Jun 2005 (EDT)


Successfully installed it on MediaWiki 1.4rc1! Thank you for upgrading code and thank you Xangelusx for the modification. Even Laner's portion works too.

  • I placed <div><?php echo kwBreadCrumbsTAL() ?></div> at line 71 of MonoBook.php

Jctong 21:21, 8 Jun 2005 (EDT)

Trim prefixes array

What is the proper usage of this setting in the extension? I am trying to remove Special:, User:, etc...

 $trim_prefixes = array();

Toykilla 15:19, 3 Aug 2005 (EDT)

I'm not sure what's unclear... Check the example section, there is an explicit use of the trim_prefix option to remove the User: from the title. You can specify as many as you want, i.e. trim_prefix=User:|trim_prefix=Special:, etc.

Success with MediaWiki 1.5.0

This is a great extension! It solves many problems and adds a great tool in a very elegant way. Just thought you would like to know that I succeeded in getting this extension to work with MediaWiki 1.5.0. I only needed to change one line in kwBreadCrumbs.php. The table cur was removed, and I think it was replaced with page. Thus, simply change the following line (approx. 429):

 $sql = "UPDATE cur SET cur_touched='$now' WHERE cur_namespace=$ns AND cur_title='$ti'";

to:

 $sql = "UPDATE page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'";

Do'nt forget to add your table-prefix to 'page'.HeinzJ 07:28, 12 Dec 2005 (EST)

FYI, I have the following in my LocalSettings.php file:

 #Add breadcrumb extension
 include("extensions/kwBreadCrumbs.php");
 $wgKwBreadCrumbs = "prefix=Trace: |small=1|bgcolor=F9F9F9";

and the following in my MonoBook.php file:

<div><?php echo kwBreadCrumbsTAL() ?></div>

As to where to place said <div>. Just after the

 <h1 class="firstHeading"><?php $this->text('title') ?></h1> 

line in MonoBook.php (v1.5.5 in my case) drops the breadcrumb below the page title. A suggestion. --Bo 23:11, 4 Feb 2006 (EST)

My SQL Error

I'm getting a strange MySQL error within the Wiki when I use the 1.5 mod:

A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:

    (SQL query hidden)

from within function "kwBreadCrumbsNoCache". MySQL returned error "1146: Table 'jordan.page' doesn't exist (sql.jordan.jorvad.com)".

Does that mean anything to anyone?


Solved

If you have a prefix for your mediawiki tables, you need to alter the line:

$sql = "UPDATE page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'";

to

$sql = "UPDATE mw_page SET page_touched='$now' WHERE page_namespace=$ns AND page_title='$ti'";

(Note, only the first instance of "page" gets the prefix.)

Bread Crumbs with links

Hi, I try to implement this extension the way it is done on this site. Calling the extension with its markup works fine, but I do not succeed in adding the link to the corresponding page. It seems the site is using kw_include_file, but the same code on my page doesn't works, the kwBreadCrumbs.php page always gives a blank response. Did I have missed something ?

Supressing Bread Crumbs when 'Printable version' is selected

This is a patch for kwBreadcrumbs.php (tested with MediaWiki 1.5.0) that stops the Bread Crumb list from being displayed if the user has chosen the 'Printable version' link from the standard toolbox. I'm new to hacking MediaWiki so there may be a better way of doing this...

 function kwBreadCrumbs($input)
 {
-  global $wgUser, $wgTitle, $wgOut;
+  global $wgUser, $wgTitle, $wgOut, $wgRequest;
+
+  // Skip if producing 'Printable version'
+  if ($wgRequest->getVal('printable')=="yes") return "";

   kwBreadCrumbsNoCache();

Multibyte characters

There is one line of code in the kwBreadCrumbs function , that messes up multibyte characters.

     $text = substr($text, 0, $max_title_len - $half - 1) . htmlentities('&hellip;') .
     substr($text, -$half);

It cuts them up in half, so the neigbhoring characters of &hellip; are invalid Bandito 05:23, 20 March 2006 (EST)

Problems with search engines and W3C validation

Breadcrumbs embedded a session id in all my internal wiki links. As a result, my pages were not indexed by Google. Also, they would not pass W3C validation for XHTML because the embedded session ids included a bare '&' instead of '&amp'. Unfortunately, I've had to remove breadcrumbs.

Problems with user page

When I go to the user page to try to get this download I get a PHP error. Is there any other place I can download this?