I think you might be happier if you split the functionality into two different controllers.

I have modified the default pages controller to add a few tweaks by first copying it to my app directory.  I then renamed it to static_controller.php, modifying the code and the views directory appropriately.

I then created my own new 'pages_controller.php' which is actually a content management system.

The way the default pages controller (which is now my 'static' controller) is setup it is not meant to have multiple actions defined.

On 9/14/06, Chris Lamb <[EMAIL PROTECTED]> wrote:


Evening.

On Thu, 14 Sep 2006 14:43:17 -0700, [EMAIL PROTECTED] wrote:

> I have added my own function to the pages_controller:
>
> function test() {
>       $this->set('abc', 'something');
> }

> The controller does load the correct view! (test.thtml) But the $abc
> var is Undefined!

What's happening is that the routes are configured so that all URLs in
the form "/pages/<something>" actually call the display() function in
pages_controller, regardless of what <something> is.

You can confirm this by putting " die('in test function') " inside
test() - it won't get called.


As for a solution. try adding another route in core/routes.php:

$Route->connect('/pages/test', array('controller' => 'pages', 'action'
=> 'test'));

And then modify pages_controller.php:

function test() {
        $this->set('abc', 'something');
        $this->display()
}


Might be a nicer way of doing it, however.


Regards,

--lamby


--
Chris Lamb, Cambs, UK                      WWW: http://chris-lamb.co.uk
  Q. Why is top posting bad?                             GPG: 0x634F9A20
  A. Because it breaks the logical sequence of discussion




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to