CMain::IncludeFile( string path, array params = array(), array function_params = array() )
The method IncludeFile is the main function you use to include any files within the page body, prologue or epilogue. It is the only method to use to include component. The visual aspect of the included file represents the include area.
The following buttons and icons relate to this method.
![]() | Show Include Areas button on the control toolbar. If checked, the include files become framed in colour border. The controls that may be displayed in the top right corner of the frame are described below. |
|
Include area frame controls | ||
---|---|---|
![]() | Means that the included file is a standard component shipped with the module; the component will be copied to the folder |
|
![]() | Means that the include file is stored in either /bitrix/templates/.default/ or |
|
![]() | Means that the Workflow module is installed and the include file can be edited using the workflow facilities. |
Parameter | Description |
---|---|
path | Path to the 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 include 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 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 include file. Array has the following format:array( "parameter name 1" => "parameter value 1", "parameter name 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 PHP function extract(params). |
function_params | Array with the parameters for the method. The following keys allowed.
|
The following example shows how to include a component in a page.
<? // the component displaying the information block contents $APPLICATION->IncludeFile("iblock/catalog/element.php", Array( // Type of information block "IBLOCK_TYPE" => "catalog", // information block "IBLOCK_ID" => "21", // element ID "ELEMENT_ID" => $_REQUEST["ID"], // URL to the page with the section contents "SECTION_URL" => "/catalog/phone/section.php?", // type of information block whose elements are linked to the current one "LINK_IBLOCK_TYPE" => "catalog", // ID of information block whose elements are linked to the current one "LINK_IBLOCK_ID" => "22", // property with link "LINK_PROPERTY_SID" => "PHONE_ID", // URL of the page displaying the link of linked elements "LINK_ELEMENTS_URL" => "/catalog/accessory/byphone.php?", // Fields "arrFIELD_CODE" => Array( "DETAIL_TEXT", "DETAIL_PICTURE"), // properties "arrPROPERTY_CODE" => Array( "YEAR", "STANDBY_TIME", "TALKTIME", "WEIGHT", "STANDART", "SIZE", "BATTERY", "SCREEN", "WAP", "VIBRO", "VOICE", "PC", "MORE_PHOTO", "MANUAL"), // cache time (sec.) "CACHE_TIME" => "3600", )); ?>
Example of including a file in the site epilogue.
<? // include area $APPLICATION->IncludeFile($APPLICATION->GetCurDir()."sect_inc.php", Array(), Array( "MODE" => "html",// use html editor "NAME" => "Edit include area", // tooltip text // new file template: "TEMPLATE" => "section_include_template.php" )); ?>
© 2001-2005 Bitrix | Bitrix Site Manager - Content Management & Portal Solutions |