I had this in the wrong forum so I'm moving it to a new home here in 'General Questions'. Please please please let there be an answer here :)
Hi All,
I am trying to show different news summaries on different pages. I am not very good with PHP but am trying to improve.
I've used the news article from tutorial 2 as my foundation.
For example if I have a sports news page that i want to show on some pages
and then a local news page that i want to show on some other pages etc. etc.
The plan is to have a drop down box in the cms to choose which news section to display on each page.
The problem is I can't even get a second summery to show on any page. As soon as I replicate the code, changing function and control names, the page gets a server error with no explanation.
Below are some snippets of my code.
Could anyone please take a look and explain what I'm doing wrong or suggest a better way of doing it. I've been battling this for days :(
Page.php
function NewsListGreen($num=5) {
$green = DataObject::get_one("NewsHolder");
return ($green) ? DataObject::get("NewsGreenPage", "ParentID = $green->ID", "Date DESC", "", $num) : false;
}
Page.ss
<% control NewsListGreen %>
<div class="News_listing_box"><!--start News_listing_box-->
<div class="News_listing_img"><!--start News_listing_img-->
<a href="$PageLink.Link">$Img</a>
</div><!--end News_listing_logo-->
<div class="News_link $BorderColor"><!--start News_listing_link-->
<a href="$PageLink.Link"><h2>Read More</h2></a>
</div><!--endNews_listing_link-->
</div>
<% end_control %>
HomePage.php
function NewsListGold($num=7) {
$gold = DataObject::get_one("NewsHolder");
return ($gold) ? DataObject::get("NewsGoldPage", "ParentID = $gold->ID", "Date DESC", "", $num) : false;
}
HomePage.ss
<% control NewsListGold %>
<div class="News_listing_box"><!--start News_listing_box-->
<div class="News_listing_img"><!--start News_listing_img-->
<a href="$PageLink.Link">$Img</a>
</div><!--end News_listing_logo-->
<div class="News_link $BorderColor"><!--start News_listing_link-->
<a href="$PageLink.Link"><h2>Read More</h2></a>
</div><!--endNews_listing_link-->
<% end_control %>