CakePHP
Syntax Highlighting
March 1, 2009

This is my first site where I display code. I explored many of the possible ways to do it.....using geshi or preg_match to find your tags and then make code to produce an ordered list. Thats it! All the methods create an ordered list or ol. So, since the goal is to get your site up and running as fast as possible, I used an editor and pushed the ol button and make css which formats the ol from the database. Thats all there is to it. You can go further and style keywords and give color to your functions, strings, variables, etc., but that is later if you choose to go that route..Here is my css.

 

  1. ol
  2. {
  3. width: 700px;
  4. list-style: decimal; /* for ie */
  5. list-style: decimal-leading-zero; /* better look for others */
  6. background-color: #E7E5DC;
  7. margin: 0px 0px 10px 10px; /* 1px bottom margin seems to fix occasional Firefox scrolling */
  8. padding: 0px 0px 0px 35px;
  9. color: #5C5C5C;
  10. }
  11. ol li
  12. {
  13. border-left: 3px solid #6CE26C;
  14. background-color: #f8f8f8;
  15. padding-left: 20px;
  16. line-height: 14px;
  17. }


Using Dreamweaver with Cakephp
February 2, 2012

There are many text editors out there, but I have always been content with Adobe's(Macromedia) Dreamweaver. I accepted for a long time that .thtml and .ctp files could not be easily viewed with Dreamweaver until I went searching on the internet for an answer. The solution is fairly simple so here it is.

Modifying the necessary Dreamweaver files

There are ultimately 3 files that you need to edit. The first two are located in the folder that you installed Dreamweaver, in my case this is “C:\Program Files\Adobe\Adobe Dreamweaver CS3\configuration” although I’m using the latest version of Dreamweaver previous versions also have a “configuration” folder so go there.

  1. ,MASTER,THTML,CTP:AllDocuments

Similarly add these two extensions to the “:PHP Files” line.

  1. PHP,PHP3,PHP4,PHP5,TPL,THTML,CTP:PHPFiles

Next open the “DocumentTypes” folder and edit the “MMDocumentTypes.xml” file, just open it up using notepad or wordpad. Search for the line which has an id “PHP_MySQL” and add the THTML/CTP file extensions to both the “winfileextension” and “macfileextension” so the line should read:

  1. winfileextension="php,php3,php4,php5,thtml,ctp"
  2. macfileextension="php,php3,php4,php5,thtml,ctp"

The final file is another version of the “Extensions.txt” which is located in your “Documents and Settings” Folder in my case this is “C:\Documents and Settings\Maestro\Application Data\Adobe\Dreamweaver 9\Configuration” just add the very same things you inserted earlier.

Finishing Up

Restart Dreamweaver and you should now be able to open up and edit .THTML and .CTP files with everything nicely colour coded. A short post but a needed one for those who use Dreamweaver.



Link tables without belongsTo
March 12, 2012

I refused to use belongsTo or hasMany for simple applications. Some code is easier to use in procedural php than in frameworks. Here is an easy way to link 2 tables together. Cakephp seems to be all about arrays.This code goes in the controller.

  1. function lists() {
  2.   $id = $this->Ffarticle->id;
  3.   $ffarticles = $this->Ffarticle->find('all', array('conditions' => array('Ffarticle.link' => $id)));
  4.     if(isset($this->params['requested'])) {
  5.     return $ffarticles;
  6.     }
  7. }

You could put the code in the model...maybe even order the query like this...

  1. class Ffarticle extends AppModel
  2. {
  3.     var $name = 'Ffarticle';
  4.     function lists($id = NULL) {
  5.         if(is_array($id)) {
  6.             $results = $this->find( 'all', array('conditions'=>array('Ffarticle.link'=>$id),'order' => 'Ffarticle.date ASC' ));        
  7.         return $results;
  8.         }
  9.     }
  10. }



This side banner is Jquery.

Jquery can give your site life. Besides creating games, you can animate anything you want to.


Coming Soon

This text will be a news feed.


 
 
Powered by
    © 2017  Maestrographics.net
 
 
(default) 24 queries took 7 ms
NrQueryErrorAffectedNum. rowsTook (ms)
1DESCRIBE `ffarticles`10101
2DESCRIBE `caketemplates`221
3SELECT `Caketemplate`.`id`, `Caketemplate`.`name` FROM `caketemplates` AS `Caketemplate` WHERE `Caketemplate`.`id` = 1 110
4DESCRIBE `mettas`880
5SELECT `Metta`.`id`, `Metta`.`controller`, `Metta`.`title`, `Metta`.`desc_name`, `Metta`.`desc_content`, `Metta`.`keywords`, `Metta`.`logo`, `Metta`.`updated_at` FROM `mettas` AS `Metta` WHERE `Metta`.`controller` = 'ffarticles' 110
6SELECT COUNT(*) AS `count` FROM `ffarticles` AS `Ffarticle` WHERE 1 = 1 110
7SELECT `Ffarticle`.`id`, `Ffarticle`.`order`, `Ffarticle`.`heading`, `Ffarticle`.`article`, `Ffarticle`.`image1`, `Ffarticle`.`image2`, `Ffarticle`.`image2_text`, `Ffarticle`.`code`, `Ffarticle`.`link`, `Ffarticle`.`date` FROM `ffarticles` AS `Ffarticle` WHERE 1 = 1 LIMIT 2014140
8SELECT COUNT(*) AS `count` FROM `ffarticles` AS `Ffarticle` WHERE 1 = 1 110
9SELECT `Ffarticle`.`id`, `Ffarticle`.`order`, `Ffarticle`.`heading`, `Ffarticle`.`article`, `Ffarticle`.`image1`, `Ffarticle`.`image2`, `Ffarticle`.`image2_text`, `Ffarticle`.`code`, `Ffarticle`.`link`, `Ffarticle`.`date` FROM `ffarticles` AS `Ffarticle` WHERE 1 = 1 LIMIT 2014140
10DESCRIBE `fftopics`551
11SELECT `Fftopic`.`id`, `Fftopic`.`topic`, `Fftopic`.`art_num`, `Fftopic`.`sub_id`, `Fftopic`.`total` FROM `fftopics` AS `Fftopic` WHERE `Fftopic`.`id` = 2 110
12SELECT `Fftopic`.`id`, `Fftopic`.`topic`, `Fftopic`.`art_num`, `Fftopic`.`sub_id`, `Fftopic`.`total` FROM `fftopics` AS `Fftopic` WHERE `Fftopic`.`id` = 2 110
13SELECT `Ffarticle`.`id`, `Ffarticle`.`order`, `Ffarticle`.`heading`, `Ffarticle`.`article`, `Ffarticle`.`image1`, `Ffarticle`.`image2`, `Ffarticle`.`image2_text`, `Ffarticle`.`code`, `Ffarticle`.`link`, `Ffarticle`.`date` FROM `ffarticles` AS `Ffarticle` WHERE `Ffarticle`.`link` = 2 ORDER BY `Ffarticle`.`order` ASC 330
14DESCRIBE `photos`551
15DESCRIBE `albums`771
16SELECT `Album`.`id`, `Album`.`name`, `Album`.`menu_name`, `Album`.`file_name`, `Album`.`title`, `Album`.`big_file`, `Album`.`small_file` FROM `albums` AS `Album` WHERE 1 = 1 330
17SELECT COUNT(*) AS `count` FROM `fftopics` AS `Fftopic` WHERE 1 = 1 110
18SELECT `Fftopic`.`id`, `Fftopic`.`topic`, `Fftopic`.`art_num`, `Fftopic`.`sub_id`, `Fftopic`.`total` FROM `fftopics` AS `Fftopic` WHERE 1 = 1 LIMIT 20550
19DESCRIBE `ffsites`441
20SELECT COUNT(*) AS `count` FROM `ffsites` AS `Ffsite` WHERE 1 = 1 110
21SELECT `Ffsite`.`id`, `Ffsite`.`link`, `Ffsite`.`image`, `Ffsite`.`caption` FROM `ffsites` AS `Ffsite` WHERE 1 = 1 LIMIT 20330
22DESCRIBE `banners`551
23SELECT `Banner`.`id`, `Banner`.`topic`, `Banner`.`text`, `Banner`.`link`, `Banner`.`date` FROM `banners` AS `Banner` WHERE 1 = 1 220
24SELECT `Banner`.`id`, `Banner`.`topic`, `Banner`.`text`, `Banner`.`link`, `Banner`.`date` FROM `banners` AS `Banner` WHERE 1 = 1 220