Jump to content

Topic on Project:Support desk

[RESOLVED] How to use <references /> within parser function? / Display a custom header above references

8
Stefahn (talkcontribs)

I have been trying to get an answer to this question since November 2012:
How can I use <references /> within a parser function?
Please see what I've tried so far.

Thanks for any help!

Bawolff (talkcontribs)

you cannot use it as a test for #if. sorry :(


you can use it inside arguments of parser funcs that get displayed, but I don't think that is what you are asking.

Stefahn (talkcontribs)

Thanks for your reply, Bawolff.

I want the references to be added automatically if there's at least one ref tag within the wikitext.
Is there a PHP function with which I can check whether the wikitext contains a certain string (in my case "<ref") ?
If yes I could a write a small custom extension to solve my problem.

Thanks!

Ciencia Al Poder (talkcontribs)

You can add <references /> always, even if there's no <ref></ref> on the page. It won't display anything and won't give any error.

Stefahn (talkcontribs)

Yes, I know. But I also need a headline above <references />. This headline should only be displayed if there is a ref tag. Do you think I can hack into the Cite extension directly? :)

Ciencia Al Poder (talkcontribs)

You can hack into the Cite extension if you know what are you doing.

Otherwise, I'd just recommend you to add a parameter on that template and fill it manually on each page that contains ref tags, since someone had to put that template or ref tags already on the page. Basically, you're trying to automate things that already needs manual intervention.

Bawolff (talkcontribs)

yes you could hack the cite extension. Most clean way i think would be to introduce a {{numberofrefs}} magic word which would be allowed in the #if test.

if you just want to add the header for all pages pn your wiki, you could try editing the page mediawiki:cite_references_prefix on your wiki.

Stefahn (talkcontribs)

Thanks a lot for the hint with mediawiki:cite_references_prefix, Bawolff!
This was absolutely what I was looking for - works like a charm now :)

Reply to "[RESOLVED] How to use <references /> within parser function? / Display a custom header above references"