21278 Posts in 5728 Topics by 2599 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 559 Views |
-
fields available in Page_Controller

22 July 2010 at 10:07pm Last edited: 22 July 2010 10:08pm
Hi!
I create a new page type (ArticlePage.php) with a new field: date. Silverstripe create a new table articlepage in db.
If a call in my ArticlePage.ss the new field $date I can't see the value. Otherwise if a call $Title a see the name of the page. The cause is that Title filed is defined in sitetree table? to see $date i can use a query in ArticlePage.php?
-
Re: fields available in Page_Controller

22 July 2010 at 11:18pm
could you post the relevant code... I am fairly sure this should work...
-
Re: fields available in Page_Controller

23 July 2010 at 12:35am
This is my ArticlePage.php
class ArticlePage extends Page {
public static $db = array(
"date" => "Date",
);And this is my ArticlePage.ss
<div class="dashtop01">
$Title $date
</div>The first $Title variable is correct and print ArticlePage title. $Date is not correct but in my articlepage table date field is not empty
-
Re: fields available in Page_Controller

23 July 2010 at 12:40am
maybe it is todo with capitalisation? could you rename your field 'Date' instead? (or if there is a conflict 'ArticleDate'?)
what does $Created get you? (this is another 'core' field)
-
Re: fields available in Page_Controller

23 July 2010 at 1:10am
I think the problem is not the name but the field. If Ihave a core field like Title I can use $Title in my .ss file. If I have a new field, only for my new page, I can't do that. What do you think? Is this correct?
-
Re: fields available in Page_Controller

23 July 2010 at 1:14am
Maybe it is because by default you are at 'Page' level/context/control and cannot see your extended fields...
e.g. it is like your template is surrounded with
<% control Page %>
<% end_control %>How about creating a function in your controller like
function ControlArticlePage()
{
return DataObject::get_by_id('ArticlePage',$this->ID);
}<% control ControlArticlePage %>
$date
<% end_control %> -
Re: fields available in Page_Controller

23 July 2010 at 4:02am
Thanks!the last is the correct solution!!
| 559 Views | ||
|
Page:
1
|
Go to Top |


