17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1094 Views |
-
Using Variables in Controls... I think

9 September 2008 at 6:25am
Hey, this might be a dumb question, but...
I've just finished tutorial 2 and thought I'd extend the news on the homepage functionality to check that I'd understood everything. I added a check box which determines if the news shows, and a number to define how many news items show. The check box works fine and the number is stored correctly, I can view it on the page using the variable '$NumTopNews'. So far I've tried to use the '$NumTopNews' variable as an argument to the 'LatestNews' function, without any luck. E.g.
...
<% control LatestNews($NumTopNews) %>
...My guess is that this means it should go into the controller, and the number be written directly into the 'LatestNews' function, trouble is, I'm not really sure how to do that.
Could someone give me a nudge in the right direction?
Cheers,
Alex
-
Re: Using Variables in Controls... I think

9 September 2008 at 6:48am
Yup, I was being dumb, turns out it was the controller that needed to be changed:
...
function LatestNews() {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $this->NumTopNews) : false;
}
...Works great
Nice CMS by the way.
Alex
-
Re: Using Variables in Controls... I think

9 September 2008 at 9:42am
As you probably realised with <% control LatestNews($NumTopNews) %> you cant use variables as parameters to methods, its a limitation of the template syntax so you can do <% control LatestNews(10) %> rather then $NumTopNews
| 1094 Views | ||
|
Page:
1
|
Go to Top |


