Tag Archives: tips

CakePhp Tip #6: Displaying items that belong to a user

cake-logo

Displaying items that belong to a user:

One of the most common things youll do in cakephp is list items that the user should only see. For example a user should just see their “posts” listed or their “articles” etc.

CakePHP has “Magic Find Types” that can help. For example if i wanted to list all the posts of the user_id =12

In my controller i can create an action as follows;

if i wanted to list all posts of the current logged in user;

To call view this action;

Source and more info;
http://book.cakephp.org/2.0/en/models/retrieving-your-data.html

CakePhp tip #5: Joining two fields to create one

Joining two fields to create one (eg to get somebodys name by combining firstname and surname)

cake-logo

You need to create a “VirtualField” in the model;

Then in your controller, to get a drop downlist;

Credit to:
http://stackoverflow.com/questions/11822942/cakephp-display-multiple-fields-in-a-single-drop-down

Notepad++ Enable CakePhp .ctp Files

If you are writing code in Notepad++ and using Cakephp youll notice it doesnt highlight .ctp files (CakePhp View Files).

You can fix this quite easily by;

Opening;

C:\Users\[YOURNAME]\AppData\Roaming\Notepad++\

Open teh file called; langs.xml

Scroll down till you see;

  <Language name=”html” ext=”html htm shtml shtm xhtml hta”

Add ctp to the end of it;

<Language name=”html” ext=”html htm shtml shtm xhtml hta ctp”

Save it and reopn Notepad++ your .ctp files should now render correctly.

Firefox 3 – Uses Huge amounts of Ram and is slow – Solutions

I love Firefox heck who doest with the fantastic features it has but Firefox 3 is so slow it seems to take ages compared to FireFox 2 and really its just not good enough. Ive tried everything to get it work a bit better, made a new profile etc and did some searching for a solution.

It also seems that Firefox uses a huge amount of ram up to 400mb of ram on my PC and thats not unique according to the searches ive done. Ive found an addon that seems to reduce the crazy amount of ram that Firefox Uses;

AFOM – Memory Recovery & Retention For Firefox
https://addons.mozilla.org/en-US/firefox/addon/11922

Im using this addon at the moment and it does seem to work even for the latest FireFox version. There are other Tweeks and solutions on the problem and ive listed some of them below.

  1. Firefox Running Slow? Make It Fast Again Without Re-Installation
  2. Is Firefox slow for you? Here’s some tips to try which might speed it up
  3. Firefox slow? Limit history size for speed improvement
  4. This May Help Your Firefox Memory Leak

This page comes up with a FireFox tweek that ive not yet tested but it might just do the trick;

This little fix will move Firefox to your hard drive when you minimize it, and as a result it will take up less than 10MB of memory while minimized. So far, from my experiences with using this today, when you maximize Firefox it will obviously increase the memory usage. However, it does not seem to go back up to the insane amount that it was at before minimizing it. For example, Firefox was at 180MB of memory usage and then I minimized it and after a few seconds I maximized it. After maximizing it and continuing on my routine business it appeared to only have gone up to 60MB. This seems to be a good solution for me right now since I frequently maximize and minimize Firefox anyways.

  • Open Firefox and go to the Address Bar. Type in about:config and then press Enter.
  • Right Click in the page and select New -> Boolean.
  • In the box that pops up enter config.trim_on_minimize. Press Enter.
  • Now select True and then press Enter.
  • Restart Firefox.