A
A
Andrey2020-03-03 08:49:54
OctoberCMS
Andrey, 2020-03-03 08:49:54

October CMS Plugin Builder. How to replace the title of the record output page when using the RecordDetails component?

There is a record page (product)

title = "Product"
url = "/product/:slug"
layout = "default"
is_hidden = 0

[builderDetails]
modelClass = "AKk\Produkty\Models\Products"
identifierValue = "{{ :slug }}"
modelKeyColumn = "slug"
displayColumn = "slug"
notFoundMessage = "Запись не найдена!"
==
<?php
function onEnd()
{
  $this->page->title = '***********';
}
?>
==
{% set record = builderDetails.record %}
{% set displayColumn = builderDetails.displayColumn %}
{% set notFoundMessage = builderDetails.notFoundMessage %}

<section class="home">
        <div class="container">
          {% if record %}
            <div class="col-lg-6 home-about-left">
              <h1>{{ record.title }}</h1>
              <p>
                 {{ record.text|raw }}
              </p>
              
            </div>
            <div class="col-lg-6 home-about-right">
              <img class="img-fluid" src="{{record.image|media}}" alt="{{ record.title }}">
            </div>
          {% else %}
        {{ notFoundMessage }}
    {% endif %}
        </div>	
      </section>

The slug of the post is substituted in the url, but how to substitute the title of the post in the title?
I am just starting to understand php, I understand that I need to predefine a variable, but where do I get the value from and how is it done?
(what to write instead of asterisks?)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikita Khaetsky, 2020-03-12
@Kirbox

Hello, our blog already has a small article that solves your problem:
https://biz-mark.ru/blog/web-razrabotka/zamena-tit...

P
Pavel Lovtsevich, 2020-03-15
@lautsevich

Never name entities with a normal transliteration. Always carry out translated into English. Especially in your case you use both options AKk\Produkty\Models\Products.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question