本文整理匯總了PHP中Bitrix\Main\Type\Collection::firstNotEmpty方法的典型用法代碼示例。如果您正苦於以下問題:PHP Collection::firstNotEmpty方法的具體用法?PHP Collection::firstNotEmpty怎麽用?PHP Collection::firstNotEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Bitrix\Main\Type\Collection
的用法示例。
在下文中一共展示了Collection::firstNotEmpty方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: implode
if (is_array($browserTitle)) {
$APPLICATION->SetPageProperty("title", implode(" ", $browserTitle), $arTitleOptions);
} elseif ($browserTitle != "") {
$APPLICATION->SetPageProperty("title", $browserTitle, $arTitleOptions);
}
}
if ($arParams["SET_META_KEYWORDS"] === 'Y') {
$metaKeywords = \Bitrix\Main\Type\Collection::firstNotEmpty($arResult, $arParams["META_KEYWORDS"], $arResult["IPROPERTY_VALUES"], "SECTION_META_KEYWORDS");
if (is_array($metaKeywords)) {
$APPLICATION->SetPageProperty("keywords", implode(" ", $metaKeywords), $arTitleOptions);
} elseif ($metaKeywords != "") {
$APPLICATION->SetPageProperty("keywords", $metaKeywords, $arTitleOptions);
}
}
if ($arParams["SET_META_DESCRIPTION"] === 'Y') {
$metaDescription = \Bitrix\Main\Type\Collection::firstNotEmpty($arResult, $arParams["META_DESCRIPTION"], $arResult["IPROPERTY_VALUES"], "SECTION_META_DESCRIPTION");
if (is_array($metaDescription)) {
$APPLICATION->SetPageProperty("description", implode(" ", $metaDescription), $arTitleOptions);
} elseif ($metaDescription != "") {
$APPLICATION->SetPageProperty("description", $metaDescription, $arTitleOptions);
}
}
if (!empty($arResult['BACKGROUND_IMAGE']) && is_array($arResult['BACKGROUND_IMAGE'])) {
$APPLICATION->SetPageProperty("backgroundImage", 'style="background-image: url(\'' . $arResult['BACKGROUND_IMAGE']['SRC'] . '\')"');
}
if ($arParams["ADD_SECTIONS_CHAIN"] && isset($arResult["PATH"]) && is_array($arResult["PATH"])) {
foreach ($arResult["PATH"] as $arPath) {
if ($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"] != "") {
$APPLICATION->AddChainItem($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"], $arPath["~SECTION_PAGE_URL"]);
} else {
$APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);
示例2: array
if ($arParams["SET_META_KEYWORDS"] === 'Y')
{
$metaKeywords = Collection::firstNotEmpty(
$arResult["PROPERTIES"], array($arParams["META_KEYWORDS"], "VALUE")
,$arResult["IPROPERTY_VALUES"], "ELEMENT_META_KEYWORDS"
);
if (is_array($metaKeywords))
$APPLICATION->SetPageProperty("keywords", implode(" ", $metaKeywords), $arTitleOptions);
elseif ($metaKeywords != "")
$APPLICATION->SetPageProperty("keywords", $metaKeywords, $arTitleOptions);
}
if ($arParams["SET_META_DESCRIPTION"] === 'Y')
{
$metaDescription = Collection::firstNotEmpty(
$arResult["PROPERTIES"], array($arParams["META_DESCRIPTION"], "VALUE")
,$arResult["IPROPERTY_VALUES"], "ELEMENT_META_DESCRIPTION"
);
if (is_array($metaDescription))
$APPLICATION->SetPageProperty("description", implode(" ", $metaDescription), $arTitleOptions);
elseif ($metaDescription != "")
$APPLICATION->SetPageProperty("description", $metaDescription, $arTitleOptions);
}
if ($arParams["ADD_SECTIONS_CHAIN"] && !empty($arResult["SECTION"]["PATH"]) && is_array($arResult["SECTION"]["PATH"]))
{
foreach($arResult["SECTION"]["PATH"] as $arPath)
{
if ($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"] != "")
$APPLICATION->AddChainItem($arPath["IPROPERTY_VALUES"]["SECTION_PAGE_TITLE"], $arPath["~SECTION_PAGE_URL"]);
else
$APPLICATION->AddChainItem($arPath["NAME"], $arPath["~SECTION_PAGE_URL"]);