Jump to:

1374 Posts in 487 Topics by 520 members

Themes

SilverStripe Forums » Themes » Control limit in subpage(children).

Discuss SilverStripe Themes.

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

Page: 1
Go to End
Author Topic: 764 Views
  • kyhuuphat123
    Avatar
    Community Member
    3 Posts

    Control limit in subpage(children). Link to this post

    I have page:

    ProjectsAndServicesPage.php
    RecentProjectObject.php
    RecentProjectImagesObject.php
    ProjectsAndServicesPage.ss

    ProjectsAndServicesPage.php

    class ProjectsAndServicesPage extends Page {

    static $db = array(
    );
    static $has_one = array(
    'ImageListProjects' => 'Image',
    );
    static $has_many = array(
    'RecentProjectObject' => 'RecentProjectObject'
    );
    }

    RecentProjectObject.php

    class RecentProjectObject extends DataObject{
    static $db = array(

    );
    static $has_one = array(
    'ProjectsAndServicesPage'=>'ProjectsAndServicesPage'
    );
    static $has_many = array(
    'RecentProjectImagesObject'=>'RecentProjectImagesObject'
    );
    }

    RecentProjectImagesObject.php

    class RecentProjectImagesObject extends DataObject {

    static $db = array(
    );
    static $has_one = array(
    'ImageRecentObject' => 'Image',
    'RecentProjectObject' => 'RecentProjectObject',
    );

    }

    ProjectsAndServicesPage.ss

    <% control RecentProjectObject %>
    <li<% if Last %>class="last"<% end_if %>>

    <h3>$TitleProject</h3>
    <p class="welcome">$WelcomeProject</p>
    <ul class="clearfix">
    <% control getRecentProjectImagesObjects %>
    <li<% if Last %>class="last"<% end_if %>><a href="">$ImageRecentObject.CroppedImage(198,148)</a></li>
    <% end_control %>
    </ul>
    <p><span>$Designer</span>$ContentDesigner</p>
    <p><span>$ProjectManagement </span> $ContentProjectManagement</p>
    <p><span>$ProjectManager </span>$ContentProjectManager </p>
    <p><span>$Completed</span>$ContentCompleted</p>

    </li>
    <% end_control %>

    ProjectsAndServicesPage.php
    class ProjectsAndServicesPage_Controller extends Page_Controller {

    function getRecentProjectImagesObjects($limit = 3) {
    $url = $this->request->param('ID');
    return DataObject::get("RecentProjectImagesObject", "RecentProjectObjectID='$url'", "ID Asc", "", $limit);
    }

    }

    I write <% control getRecentProjectImagesObjects %>. This doesn't work. Please Help

  • stallain
    Avatar
    Community Member
    61 Posts

    Re: Control limit in subpage(children). Link to this post

    Hi,

    In the template, you access your "RecentProjectImagesObjects" when looping through the "RecentProjectObject ". I think your "getRecentProjectImagesObjects" function should be written in "RecentProjectObject.php", not in the page controller.

    764 Views
Page: 1
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.