Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Probable template error. Please, help!

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 774 Views
  • Craneway
    Avatar
    20 Posts

    Probable template error. Please, help! Link to this post

    Hi, I am making a turist site, where TourPages are listed in a TourHolder Page. But also the latest tour is shown on a HomePage. I made this according to the 2nd tutorial.

    The HomePage works fine until a TourHolder page is created. After this when previewing the HomePage in a Stage (or Live) mode I recieve the following error: "Error. The website server has not been able to respond to your request." And the same error on site flush. The HomePage URL is unchanged, i.e. "home".

    Though the TourHolder and the TourPages are displayed correctly in Stage mode.

    I suppose I have done smth wrong with the templates but can't figure it out. Could you, please, check it out?

    HomePage.php

    <?php
    /**
    * Defines the HomePage page type
    */
    class HomePage extends Page {
    static $db = array(
    "Information" => "HTMLText",
    "News" => "HTMLText"
    );
    static $has_one = array(
    );
    function getCMSFields() {
    $fields = parent::getCMSFields();

    $fields->addFieldToTab("Root.Content.Main", new HTMLEditorField("Information"), "Content");
    $fields->addFieldToTab("Root.Content.Main", new HTMLEditorField("News"), "Content");
       
    return $fields;
    }   
    }

    class HomePage_Controller extends Page_Controller {
       function LatestTour() {
          $newtour = DataObject::get_one("TourHolder");
          return ($newtour) ? DataObject::get("TourPage", "ParentID = $newtour->ID", "Date DESC", "", 1) : false;
       }
    }

    ?>

    HomePage.ss fragment:

    <div class="leftblock">
              <% control LatestTour %>
       <h3><span class="new">NEW!</span><a href="$Link" title="&quot;{$Title}&quot;">$Title</a></h3>
    <p>$Content.FirstParagraph <a href="$Link" title="&quot;{$Title}&quot;"><span class="arrow"> &rarr;</span></a></p>
             <% end_control %>
    </div>

  • Craneway
    Avatar
    20 Posts

    Re: Probable template error. Please, help! Link to this post

    Sorry, guys. I solved the problem.

    "Date DESC" parameter should be removed. Now works fine.

    774 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.