Guest User

Untitled

a guest
Jul 19th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. <?php
  2.  
  3. class Page extends SiteTree {
  4.  
  5. public static $db = array(
  6. );
  7.  
  8. public static $has_one = array(
  9. 'BannerImage' => 'Image'
  10. );
  11. function getCMSFields() {
  12. $fields = parent::getCMSFields();
  13. $fields->addFieldToTab('Root.Content.Banner', new ImageField('BannerImage', 'Banner image'));
  14. return $fields;
  15. }
  16. }
  17.  
  18. class Page_Controller extends ContentController {
  19.  
  20. public function init() {
  21. parent::init();
  22.  
  23. // Note: you should use SS template require tags inside your templates
  24. // instead of putting Requirements calls here. However these are
  25. // included so that our older themes still work
  26. Requirements::themedCSS("layout");
  27. Requirements::themedCSS("typography");
  28. Requirements::themedCSS("form");
  29. Requirements::javascript('themes/' . SSViewer::current_theme() . '/js/jquery.js');
  30. Requirements::javascript('themes/' . SSViewer::current_theme() . '/js/jquery-1.js');
  31. }
  32.  
  33. /**
  34. * Site search form
  35. */
  36. function SearchForm() {
  37. $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
  38. $fields = new FieldSet(
  39. new TextField("Search", "", $searchText)
  40. );
  41. $actions = new FieldSet(
  42. new FormAction('results', 'Search')
  43. );
  44.  
  45. return new SearchForm($this, "SearchForm", $fields, $actions);
  46. }
  47.  
  48. /**
  49. * Process and render search results
  50. */
  51. function results($data, $form){
  52. $data = array(
  53. 'Results' => $form->getResults(),
  54. 'Query' => $form->getSearchQuery(),
  55. 'Title' => 'Search Results'
  56. );
  57.  
  58. return $this->customise($data)->renderWith(array('Page_results', 'Page'));
  59. }
  60. function Year(){
  61. $StartDate = "2009";
  62. if($StartDate == Date("Y")){ return $StartDate; }
  63. else{ return $StartDate . " - " . Date("Y"); }
  64. }
  65.  
  66. }
  67.  
  68. ?>
Add Comment
Please, Sign In to add comment