Guest User

Untitled

a guest
Jul 16th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. <?php
  2. private function _distinct_pr_years() {
  3. $ID = $this->ID;
  4. $q = new SQLQuery();
  5. $q->select = array('DISTINCT YEAR(Date) SQLYear');
  6. $q->from = array("PressRelease LEFT JOIN SiteTree_Live ST ON PressRelease.ID = ST.ID");
  7. $q->where = array("ST.ParentID = {$this->ID}");
  8. $q->orderby = "Date DESC";
  9. return $q->execute();
  10. }
  11.  
  12. function PRYears() {
  13. $data = new DataObjectSet();
  14. foreach ( $this->_distinct_pr_years() as $year ) {
  15. $data->push(
  16. new ArrayData(
  17. array( 'Year' => $year['SQLYear'], 'Link' => $this->Link() . 'showyear/' . $year['SQLYear'] )
  18. )
  19. );
  20. }
  21. return $data;
  22. }
Add Comment
Please, Sign In to add comment