Nicer templates with TAL-like variables
Hello, since the default templates are simply php-files, normal usage to inject php-variables is to use, for example, div id=?php echo $id ? / In a previous project, I used PHPTAL and could include variables in templates this way: div id=${id} / which is much more readable. I wrote a hack to include into view.php. line 700: /* * hack CB to allow for nicer, TAL-like templates, * e.g. input value=${value}/ instead of * input value=?php echo $value ?/ */ $___content = file_get_contents($___viewFn); $___content = preg_replace('/\${([^}]+)}/','?php echo \$$1 ?',$___content); $___tmpFn = CACHE . md5( $___viewFn ) . .tmp; file_put_contents ( $___tmpFn, $___content ); if (DEBUG) { include ($___tmpFn); } else { @include ($___tmpFn); } unlink ($___tmpFn); /** end hack **/ Now my questions are: 1) Is it possible to do this another way, without hacking cake source? 2) Has anyone integrated PHPTAL into cake yet? Thanks, Christian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Updating HABTM relationships
It IS funny that nobody seems to have this problem since many-to-many relationships are among the most useful features of relational databases. I have also tried to understand the source code of the model but it is so complex I'd rather spend my time differently. I would welcome any moves on the sides of the CakePHP developers to make HABTM associations even more useful... Cheers, Christian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Updating HABTM relationships
This is related to http://groups.google.ch/group/cake-php/browse_frm/thread/7f26efd9e871ddf1 I have two models, References and Folders: class Reference extends AppModel { var $name = Reference; /** * associations **/ var $hasAndBelongsToMany = Folder; /** * default: no recursive retrieval **/ var $recursive = 0; } class Folder extends AppModel { var $name = Folder; var $recursive = 0; /** * many-to-many association **/ var $hasAndBelongsToMany = Reference; /** * many-to-one association **/ var $belongsTo = array ( Parent = array ( 'className' = Folder, 'foreignKey' = parent_id ) ); /** * one-to-many association **/ var $hasMany = Folder; } and a controller method that should move References from one Folder to another: class ReferencesController extends AppController { var $name = References; var $uses = array (Folder,Reference); /** * moves references to different folder **/ function move ( $sourceId, $targetId, $list ) { $ids = explode ( ,, $list ); $n = 0; $this-Reference-recursive = 1; foreach ( $ids as $id ) { $data = $this-Reference-findById ($id); $folders= $data['Folder']; $save = array(); $fIds = array(); if ( ! count ( $folders ) ) continue; // link to target folder $fIds[] = $targetId; // copy all folder ids except the source folder foreach ( $folders as $folder ) { if ( ! array_search( $folder['id'], $fIds) and $folder['id'] != $sourceId ) { $fIds[] = $folder['id']; } } $this-Reference-id = $id; $save['Folder']['Folder'] = $fIds; $this-Reference-save($save); } return true; } } It won't work. Nothing is saved.Is there a fundamental misconception on my part? The task remove association x should be a trivial one, but there is nothing in the documentation, as far as I could see. I am using model_php4.php from 1.0.1.2708 (I could not upgrade the rest because for some reason the cake gets stuck in some long loop so I reverted to 0.10... for the rest of the code). Thanks, Christian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---