Jump to:

7939 Posts in 1543 Topics by 946 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » [SOLVED] Drill down on frontpage

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2 3
Go to End
Author Topic: 2426 Views
  • dubtje
    Avatar
    Community Member
    17 Posts

    [SOLVED] Drill down on frontpage Link to this post

    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 %>

  • UncleCheese
    Avatar
    4085 Posts

    Re: [SOLVED] Drill down on frontpage Link to this post

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

  • dubtje
    Avatar
    Community Member
    17 Posts

    Re: [SOLVED] Drill down on frontpage Link to this post

    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: http://www.flickr.com/photos/dubtje/3859260597/

  • UncleCheese
    Avatar
    4085 Posts

    Re: [SOLVED] Drill down on frontpage Link to this post

    Couldn't you just do:

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

  • dubtje
    Avatar
    Community Member
    17 Posts

    Re: [SOLVED] Drill down on frontpage Link to this post

    I've tried, but this links to the homepage

  • UncleCheese
    Avatar
    4085 Posts

    Re: [SOLVED] Drill down on frontpage Link to this post

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

  • dubtje
    Avatar
    Community Member
    17 Posts

    Re: [SOLVED] Drill down on frontpage Link to this post

    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.')
    );
    }
    }

    ?>

  • UncleCheese
    Avatar
    4085 Posts

    Re: [SOLVED] Drill down on frontpage Link to this post

    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?

    2426 Views
Page: 1 2 3
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.