17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1514 Views |
-
Setting 'main' Title from within controller

3 October 2007 at 10:56pm Last edited: 11 October 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
see http://doc.silverstripe.com/doku.php?id=tutorial:4-site-search#showing_the_results -
Re: Setting 'main' Title from within controller

14 October 2007 at 5:36am
Nobody?
This even seems to crash the 'lostpassword' function, that also seems to set the title..?
-
Re: Setting 'main' Title from within controller

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...
| 1514 Views | ||
|
Page:
1
|
Go to Top |


