Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Setting 'main' Title from within controller

Go to End

3 Posts   2230 Views


Community Member, 501 Posts

3 October 2007 at 10:56pm

Edited: 11/10/2007 9:46pm

Hi guys,

I'm having this function in my TipHolder_Controller (extends Page_Controller):

function edit()
        $output = array(
			"EditForm" => $this->EditForm, 
			"Title" => "Wijzig Je Locatie"
	return $this->customise($output)->renderWith(array('EditForm', 'Page'));

When doing that I get this error:

FATAL ERROR: ViewableData_Customised::obj() 'Title' was requested from the array data as an object but it's not an object. I can't cast it.

I want to change the normal page title from within that action...
I'm actually not seeing the difference (yet) with what there's going on in the search tutorial - results method, where it's not working for me either


Community Member, 501 Posts

14 October 2007 at 5:36am


This even seems to crash the 'lostpassword' function, that also seems to set the title..?


Community Member, 44 Posts

16 January 2008 at 10:57pm

Hi dio5,

I just ran into the same problem and have a solution.

My situation was as follows: Because I needed to use the LimitWordCount method on the title of the page, I had to cast it to a text (default it is a varchar and LimitWordCount is not available on that).

So I added:

static $casting = array(
	  "Title" => "Text",

When I subsequently implemented a search (search tutorial) and added this:

$data = array(
			'Results' => $form->getResults(),
			'Query' => $form->getSearchQuery(),
			'Title' => "Search results"

I got the "I can't cast" error because now there wasn't an object to cast, but there was only a string.

I solved it by changing the Title in the $data array:

$obj = new Varchar("Title"); // Or set this to Text/etc...
$obj->setValue("This is my page title");
$data = array(
	'Results' => $form->getResults(),
	'Query' => $form->getSearchQuery(),
	'Title' => $obj

Now the title is an object and all code works happily ever after...