Various Useful Code

THL Toolbox > Developers' Zone > Web Development > Various Useful Code

Various Useful Code

Contributor(s): Steven Weinberger

For a link in a php file that opens in a new window: rel="external"

i18n code

If a page returns an error like this:

Notice: Undefined variable: i18n in /sds.pri/dev/projects/thlib.org/releases/trunk/encyclopedias/literary/canons/side-column.php on line 10 Fatal error: Call to a member function translate() on a non-object in /sds.pri/dev/projects/thlib.org/releases/trunk/encyclopedias/literary/canons/side-column.php on line 10  
in /literary/canons/side-column.php line 10 is this:
  <h4 id="side-home-link"><a href="/encyclopedias/literary/" title="Literary Encyclopedia Home"><? echo $i18n->translate('Literary Home'); ?></a></h4>

Then you need to add a line of code at the top of the index.php file so that it looks like:

<? $droot = $_SERVER['DOCUMENT_ROOT'];  
include_once "$droot/global/php/thl-i18n-translator.php"; ?>

Provided for unrestricted use by the external link: Tibetan and Himalayan Library