A
A
Alexey Evlait2017-10-17 12:14:57
1C-Bitrix
Alexey Evlait, 2017-10-17 12:14:57

How to close a specific link in a menu from indexing?

Thanks for taking the time to answer my question!
The situation is the following.
Unfortunately, I have no experience with Bitrix - I'm just learning
We set a task: part of the menu on all pages, except for the main one, must be closed in noindex (certain items).
The menu is displayed through the Bitrix tools.
How to implement it?
If statics were displayed through normal html - there are no questions ...
I thought about setting a class for these items through advanced parameters, and then in the output of the component, check first for the active page (if not the Main one), and then for the presence of a class for the link and display the variant with the list item wrapped in noindex.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Evlait, 2017-10-17
@JustFeeLin

Many thanks to everyone for the replies!
I did not clean Bitrix from excess code, since the site was just created for the test.
If anyone gives me an idea how else to optimize this colossus (in terms of checks), I will be very grateful!
Combined everything that was written and got the following (works as I need):

<?if (!empty($arResult)):?>
  <?if ($APPLICATION->GetCurPage(false) === '/'):?>
   <div class="topmenu main"><ul>


      <?foreach($arResult as $arItem):?>
        <?if($arItem["SELECTED"]):?>
          <li class="selected"><b class="r1"></b><b class="r0"></b><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a><b class="r0"></b><b class="r1"></b></li>
        <?else:?>
          <li><b class="r1"></b><b class="r0"></b><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a><b class="r0"></b><b class="r1"></b></li>
        <?endif?>

      <?endforeach?>
    </ul>
  </div>	

<?else:?>
  <div class="topmenu"><ul>
      <?foreach($arResult as $arItem):?>
        <?if($arItem["SELECTED"]):?>
          <li class="selected"><b class="r1"></b><b class="r0"></b><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a><b class="r0"></b><b class="r1"></b></li>
        <?elseif ($arItem['PARAMS']['noindex'] === true):?>
          <li><b class="r1"></b><b class="r0"></b><noindex><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a></noindex><b class="r0"></b><b class="r1"></b></li>
        <?else:?>
          <li><b class="r1"></b><b class="r0"></b><a href="<?=$arItem["LINK"]?>"><?=$arItem["TEXT"]?></a><b class="r0"></b><b class="r1"></b></li>
        <?endif?>

      <?endforeach?>
    </ul>
  </div>	
<?endif?>

A
Artyom Luchnikov, 2017-10-17
@lu4nik

In the menu array, add a parameter to PARAMS, like so:

<?php
$aMenuLinks = Array(
    Array(
        "Пункт меню",
        "/link/",
        Array(), 
        Array(
            'noindex' => true,
        ),
        "" 
    ),
);

In the component template, it remains to check if $arItem['PARAMS']['noindex'] === true, then we wrap the link in .

A
Alexey, 2017-10-17
@insp1

if ($APPLICATION->GetCurPage(false) === '/') {
//output to the main page }
else {
//to all other pages
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question