Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, biapar, Willr, Ingo, swaiba, simon_w

[SOLVED] Drill down on frontpage


Go to End
Reply


18 Posts   2488 Views

Avatar
dubtje

Community Member, 17 Posts

26 August 2009 at 10:01pm

Edited: 27/08/2009 10:28pm

Hello,

I think it's a noob question, but I want to learn, so...

I've used the DOM to show a list of schools/organisations which are participating to an action. It works fine to show me a list of schools from a geographic region ('provincie'). In that list I only show some general information (name, address,...) but now I want to 'drill down' on a school (by clicking the name) to get some more details.

Can someone get me the way up? Tanks!

This is my code:
ActionPage.php
<?php
/**
* Defines the ActionPage page type
*/
class ActionPage extends Page {
static $db = array(
);
static $has_many = array(
'Actions' => 'Action'
);
static $allowed_children = array('ActionDetail');

public function getCMSFields () {
$f = parent::getCMSFields();
$f->addFieldToTab("Root.Content.Actions", new DataObjectManager(
$this,
'Actions',
'Action',
array('organisatie' => 'organisatie','roepnaam'=>'roepnaam','voornaam'=>'voornaam','familienaam'=>'familienaam','actief'=>'actief'),
'getCMSFields_forPopup'
));
return $f;
}
}
class ActionPage_Controller extends Page_Controller {
function ListActions() {
if(!isset($_GET['start']) || !is_numeric($_GET['start']) || (int)$_GET['start'] < 1) $_GET['start'] = 0;
$SQL_start = (int)$_GET['start'];
if(!isset($_GET['provincie'])) {
$doSet = DataObject::get(
$callerClass = "Action",
$filter = "`ActionPageID` = '".$this->ID."' AND `Actief` = 1",
$sort = "",
$join = "",
$limit = "{$SQL_start},10"
);
}
else {
$Provincie = $_GET['provincie'];
$doSet = DataObject::get(
$callerClass = "Action",
$filter = "`ActionPageID` = '".$this->ID."' AND `Actief` = 1 AND `provincie` = '$Provincie'",
$sort = "",
$join = "",
$limit = "{$SQL_start},10"
);
}

return $doSet ? $doSet : false;
}
}
?>

ActionPage.ss
$Content
<ul>
<% control ListActions %>
<li>
$organisatie, $roepnaam, $straat $nummer $postbus, $postnummer $gemeente
</li>
<% end_control %>
</ul>
<% if ListActions.MoreThanOnePage %>
<p>
<% if ListActions.PrevLink %>
<a href="$ListActions.PrevLink">&lt;&lt; Vorige</a> |
<% end_if %>

<% control ListActions.Pages %>
<% if CurrentBool %>
<strong>$PageNum</strong>
<% else %>
<a href="$Link" title="Ga naar pagina $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>

<% if ListActions.NextLink %>
| <a href="$ListActions.NextLink">Volgende &gt;&gt;</a>
<% end_if %>
</p>
<% end_if %>

Avatar
UncleCheese

4086 Posts

27 August 2009 at 1:13am

I'm not too sure what you mean. Can you provide a link or something visual to show what you're looking to do?

Avatar
dubtje

Community Member, 17 Posts

27 August 2009 at 7:19am

Hello,

I hope this screenshot explains a bit more, the site is not online, so I cannot link to a live preview
Thanks,
Jan


Link: [url]http://www.flickr.com/photos/dubtje/3859260597/[/url]

Avatar
UncleCheese

4086 Posts

27 August 2009 at 7:38am

Couldn't you just do:

<% control ListActions %>
<li>
<a href="$organistatie.Link">$organisatie</a>, $roepnaam, $straat $nummer $postbus, $postnummer $gemeente
</li>
<% end_control %>

Avatar
dubtje

Community Member, 17 Posts

27 August 2009 at 7:50am

I've tried, but this links to the homepage

Avatar
UncleCheese

4086 Posts

27 August 2009 at 7:58am

You need to be more clear. What is $organistatie?

Avatar
dubtje

Community Member, 17 Posts

27 August 2009 at 8:19am

I'm sorry for being unclear,

$organisatie is just the official name of the school or organisation; $roepnaam is the more daily used name (here in Belgium schools often have both);
so here $organisatie is something of the same level as $roepnaam or $adres

What I want: in the overview I give only some arguments of the Action-record ($organisatie, $roepnaam, $adres, $postcode and $gemeente) But there are some more arguments in use.

Maybe this additional code from Actions.php brings more clarity:

<?php
class Action extends DataObject {
static $db = array (
'organisatie' => 'Varchar(200)',
'roepnaam' => 'Varchar(200)',
'familienaam' => 'Varchar(200)',
'voornaam' => 'Varchar(200)',
'straat' => 'Varchar(200)',
'nummer' => 'Varchar(5)',
'postbus' => 'Varchar(5)',
'postnummer' => 'Varchar(4)',
'gemeente' => 'Varchar(200)',
'land' => 'Varchar(200)',
'provincie' => 'Varchar(50)',
'telefoon' => 'Varchar(200)',
'email' => 'Varchar(200)',
'scholennummer' => 'Varchar(200)',
'07_actief' => 'Boolean',
'07_aantalll' => 'Int',
'07_activiteit' => 'HTMLText',
'07_ekrant' => 'Boolean',
'08_actief' => 'Boolean',
'08_aantalll' => 'Int',
'08_activiteit' => 'HTMLText',
'08_ekrant' => 'Boolean',
'actief' => 'Boolean',
'aantalll' => 'Int',
'activiteit' => 'HTMLText',
'ekrant' => 'Boolean',
);

static $has_one = array (
'ActionPage' => 'ActionPage'
);

public function getCMSFields_forPopup () {
return new Fieldset (
new TextField('organisatie','Officiële naam van de school of organisatie'),
new TextField('roepnaam','Naam die in de praktijk gebruikt wordt voor de school of organisatie (roepnaam)'),
new TextField('voornaam','Voornaam'),
new TextField('familienaam','Familienaam'),
new TextField('straat','Straat'),
new TextField('nummer','Huisnummer'),
new TextField('postbus','Postbus'),
new TextField('postnummer','Postcode van de gemeente'),
new TextField('gemeente','Gemeente'),
new TextField('provincie','Provincie'),
new TextField('land','Land'),
new TextField('telefoon','Telefoonnummer'),
new EmailField('email','e-mailadres'),
new TextField('scholennummer'),
new CheckBoxField('actief','School/organisatie doen mee met Saved by the bell'),
new NumericField('aantall', 'Hoeveel leerlingen zullen deelnemen?(enkel cijfers)'),
new TextareaField('activiteit', 'Welke activiteiten plannen jullie?'),
new CheckBoxField('ekrant', 'Schrijf me in op de elektronische nieuwsbrief van Studio Globo.')
);
}
}

?>

Avatar
UncleCheese

4086 Posts

27 August 2009 at 8:29am

This makes no sense. organisatie is just a text field. How is Silverstripe supposed to know what that should link to? I'm having a really hard time envisioning what you're looking for. If the user types in "Some school" into the organisatie field, where is the URL for that school and how does Silverstripe know about it?

Go to Top