Re: Best Practice: Views, renderElement
Put your element code in app/view/elements and you can display them with: echo $this-renderElement(element_name); On Nov 21, 8:52 am, releod [EMAIL PROTECTED] wrote: Hello, I am wondering if there is a better approach to this built into CakePHP 1.2 Basically I have a few views, admin_create, admin_update, admin_destroy, all using the same code for the form. I have created another view file called _admin_form.ctp Right now, for example, I write: $this-renderElement('../user/_admin_form'); inside of my admin_create.ctp, is there anyway to render('_admin_form'); without needing to jump out of the current directory? (_admin_form is in the users directory along with the other views). Thanks! --~--~-~--~~~---~--~~ 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: Best Practice: Views, renderElement
From my understanding, if you have a form (or any other chunk of html) that is used by several views, then it clearly qualifies as an element. Sure, it's a private element (only used by views in /user), but still an element. You could always create subfolders under the elements folder, so you'd have $this-renderElement('user/admin_form'); to render app/views/ elements/user/admin_form.ctp. If that seems odd to you, try creating an 'elements' subfolder under app/views/user/, then registering app/views/user as a view path (in bootstrap.php), so that View::renderElement() will look there too. That feels a bit hacky, but should work. On Nov 21, 8:52 am, releod [EMAIL PROTECTED] wrote: Hello, I am wondering if there is a better approach to this built into CakePHP 1.2 Basically I have a few views, admin_create, admin_update, admin_destroy, all using the same code for the form. I have created another view file called _admin_form.ctp Right now, for example, I write: $this-renderElement('../user/_admin_form'); inside of my admin_create.ctp, is there anyway to render('_admin_form'); without needing to jump out of the current directory? (_admin_form is in the users directory along with the other views). Thanks! --~--~-~--~~~---~--~~ 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: Best Practice: Views, renderElement
Cool, thanks - makes sense. On Nov 21, 4:52 am, grigri [EMAIL PROTECTED] wrote: From my understanding, if you have a form (or any other chunk of html) that is used by several views, then it clearly qualifies as an element. Sure, it's a private element (only used by views in /user), but still an element. You could always create subfolders under the elements folder, so you'd have $this-renderElement('user/admin_form'); to render app/views/ elements/user/admin_form.ctp. If that seems odd to you, try creating an 'elements' subfolder under app/views/user/, then registering app/views/user as a view path (in bootstrap.php), so that View::renderElement() will look there too. That feels a bit hacky, but should work. On Nov 21, 8:52 am, releod [EMAIL PROTECTED] wrote: Hello, I am wondering if there is a better approach to this built into CakePHP 1.2 Basically I have a few views, admin_create, admin_update, admin_destroy, all using the same code for the form. I have created another view file called _admin_form.ctp Right now, for example, I write: $this-renderElement('../user/_admin_form'); inside of my admin_create.ctp, is there anyway to render('_admin_form'); without needing to jump out of the current directory? (_admin_form is in the users directory along with the other views). Thanks! --~--~-~--~~~---~--~~ 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: Best Practice: Views, renderElement
Another solution extend basic view class. ?php class ExView extends View { function renderPartial($name, $params = array(), $loadHelpers = false) { if ((strpos($name, '\\')===false) (strpos($name, '/')===false)) { $name = '..' . DS . Inflector::underscore($this-name) . DS . $name; } return $this-renderElement($name, $params, $loadHelpers); } } ? And set this class as default view class ?php class AppController extends Controller { var $helpers = array('Debug','Javascript','Html','Jquery'); function beforeRender() { $this-view='Ex'; return true; } } ? --~--~-~--~~~---~--~~ 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: Best Practice: Views, renderElement
Where is the best place to keep files that extend the CORE CAKE Framework? On Nov 21, 10:30 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Another solution extend basic view class. ?php class ExView extends View { function renderPartial($name, $params = array(), $loadHelpers = false) { if ((strpos($name, '\\')===false) (strpos($name, '/')===false)) { $name = '..' . DS . Inflector::underscore($this-name) . DS . $name; } return $this-renderElement($name, $params, $loadHelpers); } } ? And set this class as default view class ?php class AppController extends Controller { var $helpers = array('Debug','Javascript','Html','Jquery'); function beforeRender() { $this-view='Ex'; return true; } } ? --~--~-~--~~~---~--~~ 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: Best Practice: Views, renderElement
In place where thay should be. For view class extensisions correct place is /app/views folder BTW: @grigri Your proposiiton need aditional manual work. We need to describe each subview folder in bootstrap or create aditional code that will take time. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---