API15

JHelp/createSiteList

From Joomla! Documentation

< API15:JHelp
Revision as of 17:23, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description=== Builds a list of the help sites which can be used in a select option <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JHelp/createSi...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The "API15" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Builds a list of the help sites which can be used in a select option

[Edit Descripton]

Template:Description:JHelp/createSiteList

Syntax[edit]

createSiteList($pathToXml, $selected=null)
Parameter Name Default Value Description
$pathToXml Path to an xml file
$selected null Language tag to select (if exists)

Defined in[edit]

libraries/joomla/language/help.php

Importing[edit]

jimport( 'joomla.language.help' );

Source Body[edit]

function createSiteList($pathToXml, $selected = null)
{
        $list   = array ();
        $xml    =& JFactory::getXMLParser('Simple');
        $data   = null;
        if( !empty( $pathToXml ) ) {
                $data = file_get_contents($pathToXml);
        }

        if(empty($data))
        {
                $option['text'] = 'English (GB) help.joomla.org';
                $option['value'] = 'http://help.joomla.org';
                $list[] = $option;
        }
        else
        {
                if($xml->loadString($data))
                {
                        // Are there any languages??
                        $elmSites = & $xml->document->sites[0];

                        if (is_object($elmSites)) {

                                $option = array ();
                                $sites = $elmSites->children();
                                foreach ($sites as $site)
                                {
                                        $text                           = $site->data();
                                        $url                            = $site->attributes('url');
                                        $option['text']         = $text;
                                        $option['value']        = $url;
                                        $list[]                         = $option;
                                }
                        }
                }
        }

        return $list;
}

[Edit See Also] Template:SeeAlso:JHelp/createSiteList

Examples[edit]

<CodeExamplesForm />