17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1670 Views |
-
Adding search 2.2.2

26 June 2008 at 2:52am
Hi Everyone...
Tried adding search using the tutorial thats in the wiki, but I can't get it to work will somebody please tell me where to put in the code in page.php. This is how it looks at the moment.
<?php
class Page extends SiteTree {
static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);
static $has_one = array(
);
function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');
return $fields;}
}
class Page_Controller extends ContentController {
function init() {
parent::init();
Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
}
}?>
-
Re: Adding search 2.2.2

26 June 2008 at 2:17pm
as it should be mentioned in the tutorial but you need to add it in the Controller part as this is the class that interacts with the templates (and you need to be able to call search from the templates)
class Page_Controller extends ContentController {
function init() {
parent::init();Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
}
/* Add your 2 search methods here */
} -
Re: Adding search 2.2.2

28 June 2008 at 8:08pm
this is so wierd.... I did what you said, and even tried on a completely new install and still i get an error saying:
Parse error: syntax error, unexpected T_VARIABLE in /home/www/mywww/mysite/code/Page.php on line 25
I have tried what I think is all possible solutions but it just won't work......
-
Re: Adding search 2.2.2

28 June 2008 at 8:14pm
Parse error: syntax error, unexpected T_VARIABLE in /home/www/mywww/mysite/code/Page.php on line 25
Whats on line 25? Just probably a typo
-
Re: Adding search 2.2.2

28 June 2008 at 8:19pm
This is exactly how page.php looks when i get the error
<?php
class Page extends SiteTree {
static $db = array(
);
static $has_one = array(
);
}class Page_Controller extends ContentController {
function init() {
parent::init();
Requirements::themedCSS("layout");
Requirements::themedCSS("typography");
Requirements::themedCSS("form");
}
function SearchForm() {
$searchText = isset($this->Query) ? $this->Query : 'Search';
$fields = new FieldSet(
new TextField("Search", "", $searchText)
);
ÂÂ
$actions = new FieldSet(
new FormAction('results', 'Go')
);
ÂÂ
return new SearchForm($this, "SearchForm", $fields, $actions);
}
}?>
| 1670 Views | ||
|
Page:
1
|
Go to Top |


