On Dec 27, 2007 1:41 PM, subtropolis <[EMAIL PROTECTED]> wrote:
>
> CakePHP 1.2.x, PHP 5.1.4, Postgres8.1
>
> I've a controller for an archive for which i need to make the default
> view display the data for the present month.  The "view" action
> displays certain data given a date (for clarity's sake, i'll call my
> "view" action "foo" here):
>
> Everything aside from the displayed data is the same whether
> requesting a particular month or the default. The archive navigation
> is provided by an element included into the view. Consequently, I
> thought that I should simply call foo() from the index action in the
> controller:
>
> function foo($publish_date = null)
> {
>   $publish_date = !is_null($publish_date)
>      ? $publish_date :
>          (isset($this->params['publish_date'])
>              ? $this->params['publish_date'] : date('Y-M'));
> }
>
> function index()
> {
>   $this->foo(date('Y-M'));
> }
>
> Unfortunately, it seems that the view is chosen immediately upon
> making the controller request. Because there is no index.ctp I'm
> getting the "Missing View" error.
>
> I found some advice online to add the following to my index action:
>
> $this->view = 'foo';
>
> But this just results in an error because cake cannot find the fooView
> class, so I think this not what I'm searching for.
>
> Is there any way I can do this without copying foo.ctp to index.ctp?
> This isn't a question of making this an element, nor a layout (neither
> of those options seems at all correct). If I have to make a copy then
> so be it but it seems a poor solution. Is there another way to deal
> with this?

Let be the first person to say to you... huh?!?

I'm assuming you want to get the output of your foo() class into a
view?  You need this in your index() action if you are determined to
not use a view:

function index() {
     echo $this->foo();
}

Hope that helps.

-- 
Chris Hartjes

My motto for 2007:  "Just build it, damnit!"

@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to