Browse files

FEATURE: Implemented MemberProfileFieldsSection, which is a profile s…

…ection that displays a list of public fields.
  • Loading branch information...
1 parent feee812 commit 0229f6279a96279f9e42d4548da4282830aa5c87 @ajshort ajshort committed Dec 28, 2010
View
33 code/dataobjects/MemberProfileFieldsSection.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * A profile section that displays a list of fields that have been marked as
+ * public.
+ *
+ * @package silverstripe-memberprofiles
+ * @subpackage dataobjects
+ */
+class MemberProfileFieldsSection extends MemberProfileSection {
+
+ public function getDefaultTitle() {
+ return _t('MemberProfiles.PROFILEFIELDSLIST', 'Profile Fields List');
+ }
+
+ public function forTemplate() {
+ return $this->renderWith('MemberProfileFieldsSection');
+ }
+
+ public function Fields() {
+ $fields = $this->Parent()->Fields('"PublicVisibility" = \'Display\'');
+ $result = new DataObjectSet();
+
+ foreach ($fields as $field) {
+ $result->push(new ArrayData(array(
+ 'Title' => $field->Title,
+ 'Value' => $this->member->{$field->MemberField}
+ )));
+ }
+
+ return $result;
+ }
+
+}
View
7 css/MemberProfileViewer.css
@@ -10,4 +10,9 @@
#MemberProfileTitle { padding-bottom: 5px; border-bottom: 1px solid #999; }
#MemberProfile .memberProfileSection {
- margin-top: 10px; padding-bottom: 5px; border-bottom: 1px solid #CCC; }
+ margin-top: 10px; padding-bottom: 10px; border-bottom: 1px solid #CCC; }
+
+#MemberProfile .memberProfileFields { overflow: auto; margin: 0; }
+#MemberProfile .memberProfileFields dt {
+ clear: left; float: left; font-weight: bold; width: 80px; }
+#MemberProfile .memberProfileFields dd { float: left; }
View
6 templates/MemberProfileFieldsSection.ss
@@ -0,0 +1,6 @@
+<dl class="memberProfileFields">
+ <% control Fields %>
+ <dt>$Title</dt>
+ <dd>$Value</dd>
+ <% end_control %>
+</dl>

0 comments on commit 0229f62

Please sign in to comment.