This trick is for old cakephp 2.x versions.
There may have many elegant ways, but I discover it simple and easy for me.
From the view ( .ctp), I called them like:
It is a good software engineering practice.
If any specific .ctp needs to have different value, well option is always open to customize that single one keeping rest of 99 files reading the common Config value.
There may have many elegant ways, but I discover it simple and easy for me.
I put some variables used in multiple places site wide e.g. title, logo or something else like this:In app/Config/core.php
Configure::write('View.title', 'Test Title');
Configure::write('View.logo', 'logo.png');
From the view ( .ctp), I called them like:
I can use Configure.read in multiple .ctp files and if I need to change any variable value, I shall just do it in app/Config/core.php and done even if 100 .ctp files have used it.
<title>
<?php echo Configure::read('View.title'), ' :', $title_for_layout; ?></title>
It is a good software engineering practice.
If any specific .ctp needs to have different value, well option is always open to customize that single one keeping rest of 99 files reading the common Config value.