E
E
Eugene M2018-06-30 21:11:16
1C-Bitrix
Eugene M, 2018-06-30 21:11:16

How to write GetCurPage in Bitrix?

It is necessary that the title is not displayed in this directory and nested in it, for example /news/1/ how to do this? The code below does not display only on the /news/ root directory, but on nested ones.

<? if ($APPLICATION->GetCurPage(false) == "/news/"): ?> 
<? else: ?>
<h1 class="header_h1"><? $APPLICATION->ShowTitle(false); ?></h1>
<? endif ?>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2018-06-30
@hotwind

if(CSite::InDir('/about/')) {
// condition for the /about/ directory and all its subdirectories, for example /about/contancs/
}

O
Oleg Prilepa, 2018-07-03
@OAPrilepa

There is another approach, when a flag is set in the directory in the section properties file, for example:
/news/.section.php

<?
$sSectionName="Новости";
$arDirProperties = [
    'HIDE_H1' => 'Y',
];
?>

And then the condition is written in the page template:
<?php
if ('Y' != $APPLICATION->GetProperty('HIDE_H1')) {
  ?><h1><?$APPLICATION-ShowTitle(true);?></h1><?
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question