Welcome Guest, Not a member yet? Register   Sign In
Dynamic Meta Description
#6

There's really nothing to it, just create a _viewdata.php file in your Views folder with nothing in it.

PHP Code:
// the $data keys are the $title, $heading and $meta in the views.
// in the view where they are used. <?= $title;
?>
$data = [
        'title'   => 'My title',
        'heading' => 'My Heading',
        'meta'    => 'My Meta',
];

// Makes all the data global to all views.
echo view('_viewdata', $data);

// load your layout all the above data will be there.
echo view('your_layout_view'); 

That's all there is to it, you can also use the below in your layout's

PHP Code:
// you can also include other views in the layout like below
<?= view('_navbar'); ?>

<?= view('_sidebar'); ?>

It's very easy to do.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply


Messages In This Thread
Dynamic Meta Description - by shamzblueworld - 10-21-2017, 07:32 AM
RE: Dynamic Meta Description - by InsiteFX - 10-21-2017, 09:26 AM
RE: Dynamic Meta Description - by Jeewakapk - 12-10-2020, 02:30 AM
RE: Dynamic Meta Description - by InsiteFX - 12-10-2020, 07:50 AM
RE: Dynamic Meta Description - by Jeewakapk - 12-10-2020, 08:27 AM
RE: Dynamic Meta Description - by InsiteFX - 12-10-2020, 12:05 PM
RE: Dynamic Meta Description - by Jeewakapk - 12-12-2020, 09:44 AM
RE: Dynamic Meta Description - by luckmoshy - 01-12-2022, 12:09 PM



Theme © iAndrew 2016 - Forum software by © MyBB