Hi fellow bakers, long time no see. I have this issue: Customer hasmany users, user belongsto customer. Now, in the customerscontroller's index action I can set $this- >Customer->recursive = 1; If I then generate the views for customer, I nicely see the associated users when viewing a customer. But, this "related users" view is very similar to the index view of users, so to duplicate less code, I want to make an element called "users" which I then call from users/index and from customers/view (and from any other model who hasmany user)
So I did this, and calling it from users/index works fine. However I have the following issues with using the element from customers/view: 1) in the customerscontroller, to get an array with similar structure as the array in userscontroller I needed to do this: http://bin.cakephp.org/view/328781328 I would rather use the Set class but couldn't figure it out. Other then that, is this the correct approach? 2) I get errors related to pagination: indexes being undefined (count, page, current, options etc) See http://bin.cakephp.org/view/693626215 I tried adding this variable: var $paginate = array('Customer' => array('limit'=>25), 'User'=>array('limit'=>12)); The problems remained. I checked that when being called by customers/ view, the users element has the $paginator helper available, but still I get these errors. If I leave away all paginator related stuff from the element and replace them by their non-pagination-equivalents, it works fine. I don't really need pagination when I'm viewing users as associated items, but I would like to keep the code clean. (eg if i have to make a pagination-enabled version and non-pagination version of the element, all of this doesn't have much use anymore, although I do have several models who havemany user and which could use the same non-paginated element) Am I missing something? Isn't this the right approach? Is there a simple way to make this work nice and tight? Thanks! Dieter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---
