API15

Difference between revisions of "JModel/addIncludePath"

From Joomla! Documentation

< API15:JModel
(New page: ===Description=== Add a directory where JModel should search for models. You may either pass a string or an array of directories. <span class="editsection" style="font-size:76%;"> <no...)
 
Line 9: Line 9:
  
 
===Syntax===
 
===Syntax===
<source lang="php">static addIncludePath($path='')</source>
+
<source lang="php">addIncludePath($path='')</source>
  
 
  {| class="wikitable"
 
  {| class="wikitable"
Line 32: Line 32:
 
===Source Body===
 
===Source Body===
 
<source lang="php">
 
<source lang="php">
public static function addIncludePath($path='')
+
function addIncludePath( $path='' )
 
{
 
{
 
         static $paths;
 
         static $paths;
Line 39: Line 39:
 
                 $paths = array();
 
                 $paths = array();
 
         }
 
         }
         if (!empty($path) && !in_array($path, $paths)) {
+
         if (!empty( $path ) && !in_array( $path, $paths )) {
 
                 jimport('joomla.filesystem.path');
 
                 jimport('joomla.filesystem.path');
                 array_unshift($paths, JPath::clean($path));
+
                 array_unshift($paths, JPath::clean( $path ));
 
         }
 
         }
 
         return $paths;
 
         return $paths;

Revision as of 17:10, 22 March 2010

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]

Add a directory where JModel should search for models. You may either pass a string or an array of directories.

[Edit Descripton]

Template:Description:JModel/addIncludePath

Syntax[edit]

addIncludePath($path='')
Parameter Name Default Value Description
$path A path to search.

Returns[edit]

array An array with directory elements

Defined in[edit]

libraries/joomla/application/component/model.php

Importing[edit]

jimport( 'joomla.application.component.model' );

Source Body[edit]

function addIncludePath( $path='' )
{
        static $paths;

        if (!isset($paths)) {
                $paths = array();
        }
        if (!empty( $path ) && !in_array( $path, $paths )) {
                jimport('joomla.filesystem.path');
                array_unshift($paths, JPath::clean( $path ));
        }
        return $paths;
}

[Edit See Also] Template:SeeAlso:JModel/addIncludePath

Examples[edit]

<CodeExamplesForm />