21301 Posts in 5735 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1094 Views |
-
Tutorial 2 SS is not using the currect templates?

8 April 2010 at 1:02pm Last edited: 8 April 2010 2:03pm
Hi all,
I am attempting to go through Tutorial 2 of SS
http://doc.silverstripe.org/doku.php?id=tutorial:2-extending-a-basic-siteNow I've got all the .ss and .php pages setup.
mysite\code\ArticleHolder.php
mysite\code\ArticlePage.php
mysite\code\HomePage.phpthemes\tutorials\templates\Layouts\ArticleHolder.ss
themes\tutorials\templates\Layouts\ArticlePage.ss
themes\tutorials\templates\Layouts\HomePage.ssHave done the dev flush, flush all etc
I can create a Article, Holder, Article Page or Homepage in the admin and under behaviour page type it will show whatever I have selected.
But back on the front end none of these templates appear to be being used.I debug by going:
?showtemplate=1and it always shows
themes.tutorial.templates.Page.ssSo my created templates aren't actually being used on the front end.
Heres my class files also:
mysite\code\ArticleHolder.php
<?php
/**
* Defines the ArticleHolder page type
*/
class ArticleHolder extends Page {
static $db = array(
);
static $has_one = array(
);static $allowed_children = array('ArticlePage');
}class ArticleHolder_Controller extends Page_Controller {
}
?>
mysite\code\ArticlePage.php
<?php
class ArticlePage extends Page {static $db = array(
'Date' => 'Date',
'Author' => 'Text'
);static $icon = "themes/tutorial/images/treeicons/news";
function getCMSFields() {
$fields = parent::getCMSFields();$fields->addFieldToTab('Root.Content.Main', new CalendarDateField('Date'), 'Content');
$fields->addFieldToTab('Root.Content.Main', new TextField('Author'), 'Content');return $fields;
}
}class ArticlePage_Controller extends Page_Controller {
}
?>
mysite\code\HomePage.php
<?php
/**
* Defines the HomePage page type
*/class HomePage extends Page {
static $db = array(
);
static $has_one = array(
);static $icon = "themes/tutorial/images/treeicons/home";
}
class HomePage_Controller extends Page_Controller {
function LatestNews($num=5) {
$news = DataObject::get_one("ArticleHolder");
return ($news) ? DataObject::get("ArticlePage", "ParentID = $news->ID", "Date DESC", "", $num) : false;
}}
?>
Any help would be great
-
Re: Tutorial 2 SS is not using the currect templates?

8 April 2010 at 4:17pm
Note your Layouts folder should be called 'Layout'
-
Re: Tutorial 2 SS is not using the currect templates?

8 April 2010 at 4:20pm
Hi Will
Sorry that was a typo the directory structure is indeed
themes\tutorial\templates\Layout
Any other ideas?
-
Re: Tutorial 2 SS is not using the currect templates?

8 April 2010 at 4:25pm
Make sure you have done a ?flush=1 and your Page.ss contains a $Layout variable for getting the subtemplates in the layout folder.
-
Re: Tutorial 2 SS is not using the currect templates?

8 April 2010 at 4:37pm
Will I think $Layout might be my problem.
Where should that sit in the Page.ss file?
Here's my Page.ss
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" >
<head>
<% base_tag %>
$MetaTags
<link rel="stylesheet" type="text/css" href="tutorial/css/layout.css" />
<link rel="stylesheet" type="text/css" href="tutorial/css/typography.css" />
<link rel="stylesheet" type="text/css" href="tutorial/css/form.css" />
</head>
<body>
<div id="Main">
<ul id="Menu1">
<% control Menu(1) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the "{$Title}" page">$MenuTitle</a></li>
<% end_control %>
</ul><div id="Header">
<h1>$Title</h1>
</div>
<div id="ContentContainer">
<% if Menu(2) %>
<ul id="Menu2">
<% control Menu(2) %>
<li class="$LinkingMode"><a href="$Link" title="Go to the "{$Title}" page">$MenuTitle</a></li>
<% end_control %>
</ul>
<% end_if %><div id="Content" class="typography">
<% if Level(2) %>
<div class="breadcrumbs">
$Breadcrumbs
</div>
<% end_if %>
$Content
$Form
</div>
</div>
<div class="newsDetails">
Posted on $Date.Nice by $Author
</div>
$PageComments
<div id="Footer">
<span>This is PAGE.SS Visit <a href="http://www.silverstripe.com" title="Visit www.silverstripe.com">www.silverstripe.com</a> to download the CMS
<table width="175" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td> </td>
</tr>
</table></span>
</div>
</div>
$SilverStripeNavigator</body>
</html> -
Re: Tutorial 2 SS is not using the currect templates?

8 April 2010 at 6:34pm
Okay I found out why the template werent loading and that was because of my not reading the subtemplate section of tutorial 1.
Now that I have that all worked out, my templates load however on the Article Holder summary I just get nothing showing its blank.
Do I have to load the Article Pages in a specific way??? I have 5 top level Article Pages there, but as I said they arent shown in the Articel Holder page.
-
Re: Tutorial 2 SS is not using the currect templates?

8 April 2010 at 7:14pm
Don't worry Will got it all worked out and I am now cooking with gas. (I had to load the Article Pages underneath the Article Holder, not at the top level.)
| 1094 Views | ||
|
Page:
1
|
Go to Top |


