Skip to content

Commit

Permalink
Convert to CatalogPages
Browse files Browse the repository at this point in the history
Added Communities Page and added CatalogPage extension to page types as
well as lumberjack

TODO Get Lumberjack working on MunicipalityPage
  • Loading branch information
Richard Rudy committed Aug 30, 2015
1 parent 3f601f1 commit 2c654b0
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
Thumbs.db
code/.DS_Store
38 changes: 28 additions & 10 deletions _config/config.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
---
ListingsPage:
extensions:
- ExcludeChildren
SiteConfig:
extensions:
- RealEstateSiteConfig
Expand All @@ -11,20 +8,41 @@ File:
- RMSFileExtension
Listing:
extensions:
- 'Gallery_PageExtension'
- 'CatalogPageExtension'
- Gallery_PageExtension
- CatalogPageExtension
parentClass:
- 'ListingsPage'
- ListingsPage
sort_column: false
default_sort: 'Created ASC'

CommunitiesHolder:
extensions:
- Lumberjack

MunicipalityPage:
extensions:
- 'Lumberjack'
show_in_sitetree: false

NeighbourhoodPage:
show_in_sitetree: false

ListingUtils:
InlcudeMLS: 0


LeftAndMain:
menu_groups:
ListingAdmin: []
Content:
- HomePageAdmin
- AboutUsAdmin
- ContactUsAdmin
# - AboutUsAdmin
# - ContactUsAdmin
- ListingsPageAdmin
- CommunitiesAdmin
- CMSPagesController
- AssetAdmin
BlogAdmin: []
NeighbourhoodAdmin: []
Other:
- ReportAdmin
- AssetAdmin
- TeamAdmin
4 changes: 2 additions & 2 deletions code/ModelAdmin/NeighbourhoodAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
/**
*
* @package Realestate Listing System - Neighbourhood Admin
* @requires DataObjectAsPage, Mappable
* @requires Mappable
* @author Richard Rudy twitter:@thezenmonkey web: http://designplusawesome.com
*/
class NeighbourhoodAdmin extends DataObjectAsPageAdmin {
class NeighbourhoodAdmin extends ModelAdmin {

public static $managed_models = array(
'School'
Expand Down
19 changes: 17 additions & 2 deletions code/ModelAdmin/SinglePageAdmins.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class HomePageAdmin extends SinglePageAdmin {

}

/*
class ContactUsAdmin extends SinglePageAdmin {
private static $menu_title = "Contact";
private static $tree_class = 'Page';
Expand All @@ -20,11 +21,25 @@ class AboutUsAdmin extends SinglePageAdmin {
private static $url_segment = "about-us";
}
*/

class ListingsAdmin extends SinglePageAdmin {
private static $menu_title = "Listings";
class ListingsPageAdmin extends SinglePageAdmin {
private static $menu_title = "Listings Page";
private static $tree_class = 'ListingsPage';
private static $url_segment = "listings-page";
static $menu_icon = 'realestate/images/home.png';
}

class CommunitiesAdmin extends SinglePageAdmin {
private static $menu_title = "Communities";
private static $tree_class = 'CommunitiesHolder';
private static $url_segment = "communities-page";
//static $menu_icon = 'realestate/images/home.png';
}

class BlogAdmin extends SinglePageAdmin {
private static $menu_title = "Blog";
private static $tree_class = 'Blog';
private static $url_segment = "blog-admin";
//static $menu_icon = 'realestate/images/home.png';
}
114 changes: 114 additions & 0 deletions code/Pages/CommunitiesHolder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

class CommunitiesHolder extends Page {

/**
* Static vars
* ----------------------------------*/

private static $allowed_children = array(
'MunicipalityPage'
);

/**
* Object vars
* ----------------------------------*/



/**
* Static methods
* ----------------------------------*/



/**
* Data model
* ----------------------------------*/

private static $db = array (

);

/**
* Common methods
* ----------------------------------*/

public function getCMSFields() {
$fields = parent::getCMSFIelds();

//Create a list of Towns
$sqlQuery = new SQLQuery();
$sqlQuery->setFrom('Listing');
$sqlQuery->setWhere('CityID = 0');
$sqlQuery->selectField('Town');
$sqlQuery->setDistinct(true);
$result = $sqlQuery->execute();

$townList = '<ul>';

foreach($result as $row){
$townList = $townList.'<li>'.$row['Town'].'</li>';
}

$townList = $townList.'</ul>';

$townDisplay = LiteralField::create('TownList', $townList);

$fields->addFieldsToTab('Root.ChildPages', array(
HeaderField::create('TownHeader', 'Other Towns Used', 2),
$townDisplay
));

//Reorder Main Tab
$mainTab = $fields->fieldByName('Root.Main');
$fields->removeByName('Main');

$fields->findOrMakeTab('Root.Main', $mainTab);

return $fields;
}

public function getLumberjackTitle() {
return "Cities";
}

/**
* Accessor methods
* ----------------------------------*/



/**
* Controller actions
* ----------------------------------*/



/**
* Template accessors
* ----------------------------------*/



/**
* Object methods
* ----------------------------------*/




}


class CommunitiesHolder_Controller extends Page_Controller {

private static $allowed_actions = array (
);

public function init() {
parent::init();

}

}
56 changes: 52 additions & 4 deletions code/Pages/MunicipalityPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ class MunicipalityPage extends Community {
private static $plural_name = 'Cities';
private static $description = 'Landing Page for Target Market City';
private static $icon = 'realestate/images/communities.png';


private static $allowed_children = array(
'NeighbourhoodPage'
);

/**
* Object vars
Expand Down Expand Up @@ -46,9 +49,54 @@ class MunicipalityPage extends Community {
/**
* Common methods
* ----------------------------------*/




public function getCMSFields() {
$fields = parent::getCMSFIelds();

//Create Neighbourhood Gridfield
$pages = SiteTree::get()->filter(array(
'ParentID' => $this->ID,
'ClassName' => 'NeighbourhoodPage'
));

$gridConfig = GridFieldConfig_Lumberjack::create();

$gridConfig->addComponents(
new GridFieldSiteTreeAddNewButton('buttons-before-left')
);

$gridField = new GridField(
"Ex",
'Neighbourhoods',
$pages,
$gridConfig
);


//Create Listing Gridfield
$listings = $this->Listings();

$listingConfig = GridFieldConfig_Lumberjack::create();

$listingGrid = new GridField(
"Listings",
"Listings",
$listings,
$listingConfig
);

$tab = new Tab('NeighbourhoodsTabs', 'Neighbourhoods', $gridField);
$fields->insertAfter($tab, 'Main');

$listingTab = new Tab('ListingsTab', 'Listings', $listingGrid);
$fields->insertAfter($listingTab, 'NeighbourhoodsTabs');

//$fields->removeFieldFromTab('Root', 'ChildPages');


return $fields;
}

/**
* Accessor methods
* ----------------------------------*/
Expand Down
1 change: 1 addition & 0 deletions code/Pages/NeighbourhoodPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class NeighbourhoodPage extends Community {


private static $hide_ancestor = 'Community';
private static $allowed_children = array();

/**
* Object vars
Expand Down

0 comments on commit 2c654b0

Please sign in to comment.