Extension talk:Header Footer

From MediaWiki.org
Jump to: navigation, search

Contents

[edit] How do you use this extension?

How do you use this extension? What would an example look like?

I have now included some examples. Jean-Lou Dupont 17:03, 26 May 2007 (UTC)


[edit] Header/Footer not showing:

I've installed the extension using PEAR, along with StubManager. Everything seemed fine.

I accessed the page "www.mydomain.com/wiki/index.php/MediaWiki:Hf-nsheader-Main" and added some "test test" message in there by editing the page. However, nothing shows. Isn't this supposed to show the "test test" message in all pages in the Main namespace in my wiki? Solution: use instead "www.mydomain.com/wiki/index.php/MediaWiki:Hf-nsheader-" for the Main namespace.

[edit] A few suggestions to include in the documentation page

  • Since the extension depends on the StubManager extension, you should note in the installation instructions that StubManager must be installed and the "require_once" statement for StubManager must occur above the "require_once" statement for HeaderFooter in the LocalSettings file.
  • It appears that for pages that are subjected to both a hf-nsheader- and a hf-header-, both headers are rendered and the namespace header occurs first. You might include a description of what happens for pages that have multiple header and footer influences.

Thanks, Furboy 04:10, 7 April 2008 (UTC)

[edit] A few bugs

Confirm Delete Page
When deleting a page from a namespace that has a corresponding hf-nsheader- or hf-nsfooter- the header and/or footer are rendered on the delete confirm page.
Right-aligned table conflict
If a table with the parameter align="right" is the last wikitext on a page, the table gets covered up by the hf-nsfooter. You can work around the problem by adding enough
tags to get the table to move up, or by simply adding some text after the table.
__NOHEADER__ and __NONSHEADER__ not working
__NOHEADER__ and __NONSHEADER__ are not working for me. The documentation page says to use the magic words on "edit protected pages", which I assume means that the headers will be disabled on pages that include the magic words and that are protected. That's how I have it set up and it doesn't work.

Thanks, Furboy 04:10, 7 April 2008 (UTC)

Many thanks for the detailed bug reports. Could you use my project's issues tracking facility to document these? ( [1] ) One has much higher chances of seeing resolutions this way. Thanks again. Jean-Lou Dupont 10:09, 7 April 2008 (UTC)

[edit] Incompatibility with PHP 5.3.2

After upgrading to PHP 5.3.2 I get the following error (on any page with a header or footer):

Detected bug in an extension! Hook Stub::hOutputPageParserOutput failed to return a value; should return true to continue hook processing or false to abort.

Backtrace:

#0 /home/srv/mediawiki/mediawiki-trunk/includes/OutputPage.php(632): wfRunHooks('OutputPageParse...', Array)
#1 /home/srv/mediawiki/mediawiki-trunk/includes/OutputPage.php(640): OutputPage->addParserOutputNoText(Object(ParserOutput))
#2 /home/srv/mediawiki/mediawiki-trunk/includes/Article.php(830): OutputPage->addParserOutput(Object(ParserOutput))
#3 /home/srv/mediawiki/mediawiki-trunk/includes/Wiki.php(493): Article->view()
#4 /home/srv/mediawiki/mediawiki-trunk/includes/Wiki.php(70): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#5 /home/srv/mediawiki/mediawiki-trunk/index.php(117): MediaWiki->performRequestForTitle(Object(Title), Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
#6 /home/srv/mediawiki/mediawiki-trunk/index.php5(1): require('/home/srv/media...')
#7 {main}

This fix appears to be simple. In HeaderFooter.body.php, line 14:

 -       public function hOutputPageParserOutput( &$op, &$parserOutput )
 +       public function hOutputPageParserOutput( &$op, $parserOutput )

This is the way this hook looks in other places.

--ZbySz 14:06, 20 April 2010 (UTC)

Thanks, this helped. --Molenwiek 09:00, 15 December 2011 (UTC)

[edit] Wish List

hf-header- trumps hf-nsheader-
It appears that for pages that are subjected to both a hf-nsheader- and a hf-header-, both headers are rendered and the hf-nsheader- occurs first. For my own application, I would rather see the hf-nsheader- header get rendered in all instances where there is not a hf-header-, but that when there are both a hf-nsheader- and a hf-header-, that the hf-header- is rendered and the hf-nsheader- is not. I suppose that I could use a __NONSHEADER__ to force the override, but I haven't been to get my __NONSHEADER__ to work. Ideally, I would like to be able to put a __NONSHEADER__ in my hf-header- or a __NOHEADER__ in my hf-nsheader- to force the appropriate overrides.
Custom parameters
It would be nice to be able to pass a parameter from a page to its corresponding hf-header- page, similar to the way you can pass parameters to templates. One way might be with a hook like <hf-param>parameter name|parameter value</hf-param> that could be retrieved in the hf-nsheader- from a variable like {{#hf-param: parameter name}}.
Evaluate Cite.php
Cite.php is a citation reference extension that collects text enclosed by <ref> tags and inserts the text as a footnote in a section indicated with the placeholder tag <references/>. Some of the shortcomings of Cite.php include 1) the editor must actually remember to include the <references/> tag, 2) placing the <references/> tag is an additional task for the editor - a task that must be repeated on each page that has such references, and 3) many editors means that the location and formatting of the reference footnotes are not likely to be similar. If there was a way for HeaderFooter.php to evaluate whether a page included <ref> tags, a standard footer could be developed to the <references/> tag conditionally.

thanks, Furboy 04:10, 7 April 2008 (UTC)

Could you also add these the my project's issues/features tracking facility? Thanks. Jean-Lou Dupont 10:11, 7 April 2008 (UTC)

[edit] Thanks

Thanks for pointing me to it, works fine for me. --Subfader 09:30, 16 May 2008 (UTC)

[edit] Automatically appending categories to pages

On my wiki I have at home, I've set up this extension (and all works great). However, I have one question: how would I write the code so that when a certain header is applied to all pages of a namespace, those pages are automatically added to a certain category? For example, I have a header that goes at the top of every page in the User namespace, and I want all those pages to be in "Category:User Pages", but when I add something to the page MediaWiki:Hf-nsheader-User along the lines of <includeonly>[[Category:User Pages]]</includeonly>, nothing happens (except that the header page is added to that category). The same if I use <noinclude> tags or if I don't use tags around it at all. What should I do to fix this? ~Signed Ωmega234talk to me 02:32, 17 June 2008 (UTC)

Hi - the header and footer text are processed outside of the scope of the current page; hence, what you are trying to do won't work. You may file a feature request on GoogleCode and maybe ... ;-) Jean-Lou Dupont 02:42, 17 June 2008 (UTC)
I second this request. Would be a real killer feature :-) -- Thoralf 16:44, 28 August 2008 (UTC)

[edit] __NOHEADER__ and __NONSHEADER__ not working - my solution (NOT AN ISSUE)

Hello.

__NOHEADER__ and __NONSHEADER__ only work on pages that are protected from editing. I edited this part of HeaderFooter.body.php:

               if ($disable && $protect)
                       return null;
               return $content;

And deleted "&& $protect".

Works fine for me.

Hey that helped me out a lot! Why on earth would the author force the page to be protected for these to work? That's extremely unintuitive. I would like to see this adjustment on the extension page itself.

Many thanks to the author! 19:03, 4 July 2008 (UTC)

Hi - note that the magic words are working... but not the way you wanted. Jean-Lou Dupont 01:16, 5 July 2008 (UTC)

[edit] Header & Footer position

Hi first of all thanks for your -very useful- extension. Is it possible to change the position of the elements and to move them for example outside of <div id="content">?

[edit] Complex SItename

Hello, thanks for this extension, but it does not work for complex sitenames like:

Entw:/pk=2qrk2mn13ods8s5iReQu/AWF-REQ00000368/DOKU

I have tried with the Page "Test" - it works fine. The good way to link to the page headers(footers) is

[[MediaWiki:hf-header{{PAGENAME}}]]

In my case

MediaWiki:hf-header-Entw:/pk=2qrk2mn13ods8s5iReQu/AWF-REQ00000368/DOKU

is set correct, but the headers are not visible.

(sorry for my English) any Idea?

[edit] File ns: not footer not at end of page

Hi there. I added a footer for the File NS and the content is added right below the image desc (above the File history section). Shouldn't it be below the last section File links / Metadata? Although I see that's added below the page content which is the manually added file description. Nontheless, it looks odd. --Subfader 21:55, 1 October 2009 (UTC)

[edit] A More Efficient Implementation

If you have a lot of database inquries in your header, you might notice that using the __NONSHEADER__ command still parses the header wikitext before it inserts it into the page. So, for instance, if you have a demanding main namespace header, even though the header is disabled on Main Page, it will still incur a high server load whenever you go to the Main Page (which is clearly undesirable). I also disabled the protect-only feature which was unnecessary and confusing for most users.

Use this code instead:

<?php
/**
 * @author Jean-Lou Dupont and Douglas Mason
 * @package HeaderFooter
 * @version 2.0.1 (?)
 */
class HeaderFooter
{
        /**
         * Main Hook
         */
        public function hOutputPageParserOutput( &$op, &$parserOutput )
        {
                global $action;
                if ( ($action == 'edit') || ($action == 'submit') )
                        return true;
 
                global $wgTitle;
 
                $ns = $wgTitle->getNsText();
                $name = $wgTitle->getPrefixedDBKey();
                $protect = $wgTitle->isProtected( 'edit' ); # $protect isn't used, but it can't hurt
         
                $text = $parserOutput->getText();    
 
                $nsheader = "hf-nsheader-$ns";
                $nsfooter = "hf-nsfooter-$ns";           
 
                $header = "hf-header-$name";
                $footer = "hf-footer-$name";             
 
                $text = '<div class="hf-header">'.$this->conditionalInclude( $text, '__NOHEADER__', $header, $protect ).'</div>'.$text;
                $text = '<div class="hf-nsheader">'.$this->conditionalInclude( $text, '__NONSHEADER__', $nsheader, $protect ).'</div>'.$text;
 
                $text .= '<div class="hf-footer">'.$this->conditionalInclude( $text, '__NOFOOTER__', $footer, $protect ).'</div>';
                $text .= '<div class="hf-nsfooter">'.$this->conditionalInclude( $text, '__NONSFOOTER__', $nsfooter, $protect ).'</div>';
 
                $parserOutput->setText( $text );
 
                return true;
        } 
 
        /**
         * Verifies & Strips ''disable command'', returns $content if all OK.
         */
        protected function conditionalInclude( &$text, $disableWord, &$msgId, $protect )
        {
                // is there a disable command lurking around?
                $disable = strpos( $text, $disableWord ) !== false ;
 
                // if there is, get rid of it
                // make sure that the disableWord does not break the REGEX below!
                $text = preg_replace('/'.$disableWord.'/si', '', $text );
 
                // if there is a disable command, then don't return anything
                if ($disable)
                        return null;
 
            $msgText = wfMsgExt( $msgId, array( 'parseinline' ) );
 
                // don't need to bother if there is no content.
                if (empty( $msgText ))
                        return null;
 
                if (wfEmptyMsg( $msgId, $msgText ))
                        return null;
 
                return $msgText;
        }
 
}
thanks. It works well with 1.16.0
Thanks. Jean-Lou quit coding for MW so it's good to see some people still use it / work with it. --Subfader 21:54, 15 July 2011 (UTC)

[edit] Can't get this to work...

In the Special:Version page looks like that it's installed and looks fine.

But It doesn't work. I created the page MyWiki:Hf-nsfooter- and write "Test".

Shouldn't it work and show "Test" on every page? Am I doing something wrong?

It's resolved. I was using my wiki's name. The correct was MediaWiki:Hf-nsfooter-

[edit] Is it possible to close the header?

Just like on Wikipedia?

w:en:Main_Page

I want to put a header on my wiki, but it would be better if we could close it.

[edit] Can't get it working for the Special namespace

Can't get it working for the Special namespace. Does anybody know how to?

[edit] Why is it showing the footer on the edit page?

Hi, I'm using this extension in 2 Wiki's and in one of them it is showing the footer on the edit page while I edit. Twice on top, and once on the bottom.

Anyone can help me? I'm using MW1.18 on the Wiki with the problem.

P.S.: Sorry for my english, it's not my native language.

You can easily hide it via CSS. Check body class on page edit and hide the footer div. --Subfader 23:42, 29 January 2012 (UTC)
Personal tools
Namespaces
Variants
Actions
Site
Support
Download
Development
Communication
Print/export
Toolbox