Erm, friendlyDisplay versus friendlyName?

Of course, if your models were mixed / camel case, you could just use
the inflector and php functions to achieve this... :)

Personally, I think it's okay to let the controller attempt this bit
of view logic, seeing as the views can override it if they have reason
to - it's just a useful default.
I usually go for putting this in beforeRender, using a prettified
version of $this->action (add/edit etc) and  then the model or
controller name.


On Jun 10, 2:27 pm, Smelly_Eddie <[EMAIL PROTECTED]> wrote:
> Doesnt seem to work....
>
> My controller
>
> class CustomerproductreviewsController extends AppController {
>
>         var $name = 'Customerproductreviews';
>         var $uses = array('Customerproductreview', 'Product',
> 'Rating','User');
>         var $helpers = array('Html',
> 'Form','Pagination','Ajax','FlashChart');
>         var $components = array
> ('Glscore','Autoformat','RequestHandler','Upload','Pagination');
>
>         function beforeFilter(){
>                 $this->pageTitle= 
> $this->{$this->modelClass}->friendlyDisplay.'
> - .:: The GreenLife List ::. ';
>
>         }
> ....
>
> my model
>
> class Customerproductreview extends AppModel
> {
>     var $name = 'Customerproductreview';
>     var $friendlyName = 'Customer Product Reviews';
>         var $validate = array(
>         'title' => VALID_NOT_EMPTY,
>         'product' => VALID_NUMBER,
>         'rating' => VALID_NUMBER,
>         'reason' => VALID_NOT_EMPTY,
>     );
>         var $displayField = 'title';
>         var $recursive = 2;
> .....
>
> Am I missing something?
>
> On Jun 10, 8:56 am, grigri <[EMAIL PROTECTED]> wrote:
>
> > class Pie extends AppModel {
> >   var $friendlyName = 'A tasty treat!';
>
> >   var $actsAs = array('Tasty'); // Optional
>
> > }
>
> > class AppController extends Controller {
> >   function beforeFilter() {
> >     if (!empty($this->modelClass)) {
> >       $this->set('title', $this->{$this->modelClass}->friendlyName . '
> > - foooooooooood');
> >     }
> >   }
>
> > }
>
> > Although... some might question the wisdom of setting a view-level
> > parameter in the controller and the model.
>
> > hth
> > grigri
>
> > On Jun 10, 1:37 pm, Smelly_Eddie <[EMAIL PROTECTED]> wrote:
>
> > > I have always used the function below in my controllers to set the
> > > page's title.
>
> > > function beforeFilter(){
> > >                 $this->pageTitle= $this->name.' - .:: The GreenLife List 
> > > ::. ';
>
> > > }
>
> > > The problem is that some model names are concatenated due to their
> > > HABTM nature, like "customerproductreviews"
>
> > > I thought I could just set a variable in the Model like
> > > '$displayName',  but the controllers don't see such a variable.
>
> > > I know there must be a way to assign readable and formatted model
> > > names to use in the page title.
>
> > > It wold also be useful when other models read related data, the bake
> > > script could show "related customer reviews" in my other models,
> > > rather than the ugly one word name.
>
> > > Any help?, yes I have tried google, but what to search?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to