![]() |
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 = [ PHP Code: <?php if(isset($meta_title) && !empty($meta_title)): ?> 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 ---
It depends on the title, is it ever going to change?
if not then hard code it into the view. else save in database and assin it to $data array and pass it to the view. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
@InsiteFX is right. It depends but I would go with the first option but not typing this way
PHP Code: <?php if(isset($meta_title) && !empty($meta_title)): ?> but shortly this way PHP Code: <title><?php echo $title ?? 'No title' ; ?></title>
Don't forget `esc()`.
Hello,
Thank you for your reply ? So I will continue to use the Controller method to manage Meta tags --- I am not a developer ---
|
Welcome Guest, Not a member yet? Register Sign In |