4

This is more of a general information question involving endnotes than a "check my code" one. That's because I can find almost no (useful) information on the subject and don't have the skills to create this myself. But I still think it's useful to create a general brainstorm session / forum thread on the net about this.

The issue: I've written about 60 articles, a dozen of them book-length or near book-length on a site that has been manually designed with HTML5, CSS3, jquery and PHP - the latter two mainly with pre-existing code. I'm very happy with it except for one thing: endnotes! It takes forever to update them.

An average article has 120 endnotes (up to 550). It happens frequently, especially during the writing/proofreading process, that I need to add more information or want an additional endnote. That means anywhere from 2 to 30 minutes of copy-pasting "[113]s", "[114]s" around. It's hopelessly inefficient.

Ordinarily I dislike the uninspirational Wiki CMS platforms, but they have one huge benefit: cite.php plugins. Like this one:

https://www.mediawiki.org/wiki/Special:ExtensionDistributor?extdist_name=Cite&extdist_version=REL1_26&extdist_submit=

Once you have this, you just put an URL between <ref> </ref> and an endnotes gets automatically generated below a {{reflist}} tag. It's explained here:

https://en.wikipedia.org/wiki/Help:Footnotes

Footnotes are created using the Cite.php software extension. This extension adds the HTML-like elements <ref>...</ref>, <references /> and <references>...</references>. The elements are also used in a number of templates; for example, it is becoming more common to use {{reflist}} rather than <references /> as it can style the reference list.

I've checked out the plugin and it, of course, is much more than just a few lines of PHP.

My main question is if anyone is aware if this type of code has been created for custom designed websites. Or if someone has an idea how to program this manually? If it's not too hard, I might try it myself in the near future or hire a programmer.

P.S. I did study HTML5 solutions for endnotes in the past. Can't remember the details, but they were terrible. It's crucial to have one type of tag, with each one generating a new automatic endnote.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Jake145
  • 81
  • 5
  • I'm not sure that I understood your question. Are you asking how to use this plugin on your website? – A.L Feb 27 '16 at 23:36

2 Answers2

1

{{ }} is not standard HTML tags, but usually in some modern MVC frameworks they are used as replacement for PHP syntax like echo $foodNote which is the same as {{ $foodNote }}.

A MVC framework like Laravel use it as part of blade template.

But in the provided link you have in your question, the {{reflist}} is just referring to the content inside the tags like <ref>Content of the reference</ref>.

The provided Cite.php helper file is parsing the content inside tags like <ref>...</ref> to variable reflist inside a curly braces with the same content.

It should be not very difficult to program such thing.

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137
0

Here is a simple PHP script to handle footnotes automatically. The only significant caveat is that your web page file name must end in .php or .phtml (not all web servers support .phtml). This is no problem because the web server will treat the file exactly as a .html file, except it watches for PHP tags so it can process the embedded PHP scripts.

Here is the script.

<?php
function footnote($footnote){
  global $Footnotes, $FootnoteCount;
  $FootnoteCount++;
  $Footnotes[$FootnoteCount] = "$footnote";
  print "<sup>$FootnoteCount</sup>";
}
    
function PrintFootnotes(){
  global $Footnotes, $FootnoteCount;
  for($i = 1;$i < $FootnoteCount + 1;$i++){
    print "<sup>$i</sup>$Footnotes[$i]<br />";
  }
}
?>

You can put the script at the top of each page.

Better yet, save the script in a file named FootnoteFunctions.php. Of course, you can name it what you want or put it in a file with other functions. Just change the following include as appropriate. Next, put the following in the head of your HTML document:

<?php include("FootnoteFunctions.php"); ?>

Put this where you want the footnotes to appear at the bottom of the page:

<?php PrintFootnotes(); ?>

To create a footnote insert the following where you want the footnote number in the text (with your text between the quotes):

<?php footnote("footnote text here") ?>

That's it.

You can embellish the script as desired. For example, to pop up the footnote text as a tooltip, add title="$footnote" to the tag. You can also put a table tag, etc, in the printing function to make the footnote numbers and text line up nicely.

Here is my page explaining line by line how the script works. It also has an embellished version with the features mentioned above.

https://vocademy.net/textbooks/WebDatabase/Footnotes/PageSetup.php?Page=3&CourseDirectory=WebDatabase

rsduhamel
  • 1
  • 1