Pages

Monday, May 23, 2016

Cakephp 2.x site wide view variables

This trick is for old cakephp 2.x versions.

There may have many elegant ways, but I discover it simple and easy for me.

In app/Config/core.php
I put some variables used in multiple places site wide e.g. title, logo or something else like this:


Configure::write('View.title', 'Test Title');
Configure::write('View.logo', 'logo.png');


From the view ( .ctp), I called them like:

<title>
 <?php echo Configure::read('View.title'), ' :', $title_for_layout; ?>
</title>
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.

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.

Thursday, May 5, 2016

Ubuntu No Sound problem fixing

If a terminal (gnome-terminal or xterm whatever is available) type:

aplay -l


If you see this:
aplay: device_list:221: no soundcard found...
Then type

sudo aplay -l

The output of that command should look something like this:
 
**** List of PLAYBACK Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC861VD Analog [ALC861VD Analog]
  Subdevices: 0/1
  Subdevice #0: subdevice #0
It means your sound card is okay and your problem may solve easily by adding your username into audio group. Now type
grep ^audio /etc/group

to check if your username is there, if not add it:
sudo addgroup <username> audio
 <username> will be your login name ( whoami or w will reveal your username if you are not sure)

You can also do:

sudo addgroup `whoami` audio
 Note the inverted single quote ( ` ), it is crucial.


For more complex issues please visit official ubuntu sound troubleshooting help