IncludeFile
CMain::IncludeFile( string path, array params = array(), array function_params = array() )
The method is the main function you use to include any files within the page body, prologue or epilogue. It is the only method that can be used to include components. The visual aspect of the included file represents the include area. Non-static method.
Parameters
Parameter | Description |
---|---|
path | Path to included file.
If the parameter contains the path relative to the site root, the method includes this file unconditionally. If the file cannot be found and the button "Show included areas" is checked, the frame-placeholder contains the blue button linked to the page allowing to create a new file in the folder specified in the parameter path. If this parameter contains path relative to the included file, the system will deem this file as a component and will show the edit button in the edit mode. If the parameter specifies the path to the main file of the component, the method attempts to find and include the file using the following rules:
|
params | Array of parameters to be passed to the included file. Array has the following format:
array( "ИМЯ_ПАРАМЕТРА_1" => "PARAMETER_VALUE_1", "ИМЯ_ПАРАМЕТРА_2" => "PARAMETER_VALUE_2", ...)The include file initialises variables with names taken from the array keys; the variables values are the corresponding values of the array. This operation is performed using the standard extract(params) PHP function. |
function_params | Array with the parameters for the method. The following keys allowed:
|
See Also
Example of including a component on the page
<? // the component displaying the information block contents $APPLICATION->IncludeFile("iblock/catalog/element.php", Array( "IBLOCK_TYPE" => "catalog", // Type of information block "IBLOCK_ID" => "21", // information block "ELEMENT_ID" => $_REQUEST["ID"], // element ID "SECTION_URL" => "/catalog/phone/section.php?", // URL to the page with the section contents "LINK_IBLOCK_TYPE" => "catalog", // type of information block whose elements are linked to the current one "LINK_IBLOCK_ID" => "22", // ID of information block whose elements are linked to the current one "LINK_PROPERTY_SID" => "PHONE_ID", // property with link "LINK_ELEMENTS_URL" => "/catalog/accessory/byphone.php?", // URL of the page displaying the link of linked elements "arrFIELD_CODE" => Array( // Fields "DETAIL_TEXT", "DETAIL_PICTURE"), "arrPROPERTY_CODE" => Array( // Properties "YEAR", "STANDBY_TIME", "TALKTIME", "WEIGHT", "STANDART", "SIZE", "BATTERY", "SCREEN", "WAP", "VIBRO", "VOICE", "PC", "MORE_PHOTO", "MANUAL"), "CACHE_TIME" => "3600", // Cache time (sec.) )); ?>
Example of including a file in the site epilogue.
<? // included area for the section $APPLICATION->IncludeFile($APPLICATION->GetCurDir()."sect_inc.php", Array(), Array( "MODE" => "html", // use html editor "NAME" => "Edit the section included area", // tooltip text on a popup icon "TEMPLATE" => "section_include_template.php" // template name for the new file )); ?>
© «Bitrix24», 2001-2024