Welcome Guest, Not a member yet? Register   Sign In
Title in View or in Controller [SOLVED]
#1
Information 
(This post was last modified: 06-27-2022, 07:05 AM by InstantT.)

Hello all,
I wonder what is the best way to display the Title tag.

Is it better to display it in the View or in the Controller?

Controller Example

PHP Code:
$data = [
    'meta_title' => "Blog Post ".$post_name,
];

return 
view('my-view'$data); 

PHP Code:
<?php if(isset($meta_title) && !empty($meta_title)): ?>
    <?= '<title>'.esc($meta_title).'</title>'?>
<?php 
endif; ?>

But I wonder if it's better to fill in the Title tags in the Views with renderSection

PHP Code:
<title><?= $this->renderSection('title'?></title> 

PHP Code:
<?= $this->section('title'?> Blog Post <?= esc($post_name); ?> <?= $this->endSection() ?>

What is the best option?

Thank you in advance for your answer.
--- I am not a developer ---
Reply


Messages In This Thread
Title in View or in Controller [SOLVED] - by InstantT - 06-25-2022, 08:21 AM
RE: Title in View or in Controller - by InsiteFX - 06-26-2022, 12:35 AM
RE: Title in View or in Controller - by demyr - 06-26-2022, 02:52 AM
RE: Title in View or in Controller - by kenjis - 06-26-2022, 04:59 PM
RE: Title in View or in Controller - by InstantT - 06-27-2022, 07:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB