download201401 2015-01-24 10:31 采纳率: 0%
浏览 55

SilverStripe主题无法识别主页主题

I have just restored a SilverStripe website which involved updating silverStripe from version 2.4 to the current version (3.1.9). I copied all the content, backed up the database and saved the template before deleting and reinstalling the site.

The website is using a custom theme which I have been able to copy back into the /Themes folder and then pick the correct theme in the settings.

I have two problems now and as I haven't changed anything I am not sure why its not working

First: SilverStripe isn't recognising the Home Page template SilverStripe is just reading the general Page template

HomePage.ss

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <% base_tag %>
    $MetaTags(false)
    <title>$Title - Furturo - Design. Build. Outdoor</title>
    <script type="text/javascript" src="themes/forturo/javascript/jquery-1.3.2.min.js"></script>
    <script src="themes/forturo/javascript/jquery.innerfade.js" type="text/javascript"></script>
    <script type="text/javascript" src="themes/forturo/javascript/forturo.js"></script>

    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-56783648-1', 'auto');
    ga('send', 'pageview');

    </script>

    <% require themedCSS('reset') %>
    <% require themedCSS('reset-font-grids') %>
    <% require themedCSS('sifr') %>
    <% require themedCSS('forturo') %>
    <title>Forturo</title> 
    </head>
    <body id="home">
    <div id="custom-doc" class="yui-t7">
    <div id="bg">

    <div id="hd">
    <img src="themes/forturo/images/design-top-left.gif" alt="" id="top-left">
    <h1>Forturo - Design. Build. Outdoor - Architectural Design. Draughting. Building Services</h1>
    <% include HomeNav %>
    </div>
    <div id="bd">
    <div class="yui-gd">
    <div id="pngwrap">
    <img src="themes/forturo/images/home/home-blue-stripe.png" alt="" width="123" height="631" id="blue">
    <img src="themes/forturo/images/home/home-green-stripe.png" alt="" width="123" height="631" id="green">
    <img src="themes/forturo/images/home/home-orange-stripe.png" alt="" width="123" height="631" id="orange">
    </div>
    <div class="yui-u first nav">
    </div>
    <div class="yui-u second">
    <div id="rotatingImageHolder">
    <ul id="mainImage">
          <% if HomePageImage1 %><li><img src="$HomePageImage1.URL" alt="" class="image3"></li><% end_if %>
          <% if HomePageImage2 %><li><img src="$HomePageImage2.URL" alt="" class="image2"></li><% end_if %>
          <% if HomePageImage3 %><li><img src="$HomePageImage3.URL" alt=""  class="image1"></li><% end_if %>
          <% if HomePageImage4 %><li><img src="$HomePageImage4.URL" alt=""  class="image4"></li><% end_if %>
          <% if HomePageImage5 %><li><img src="$HomePageImage5.URL" alt=""  class="image4"></li><% end_if %>
          <% if HomePageImage6 %><li><img src="$HomePageImage6.URL" alt=""  class="image4"></li><% end_if %>
    </ul>

    </div>

    <div>
    <a href="Design" class="design-button button">Design</a>
    <a href="Outdoor" class="outdoor-button button">Green</a>
    <a href="Build" class="build-button button">Build</a>
    </div>
    </div>
    </div>

    </div>
    <div id="ft">
    <div id="textholder"></div>
    </div>
    </div><!-- /#bg -->
    </div>
    </body>
    </html>

Page.ss

   <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <% base_tag %>
    $MetaTags(false)
    <title>$Title - Forturo - Design. Build. Outdoor</title>
    <% require themedCSS('reset') %>
    <% require themedCSS('reset-font-grids') %>
    <% require themedCSS('sifr') %>
    <% require themedCSS('forturo') %>

    <!-- sifr scripts -->
    <script src="/themes/forturo/javascript/sifr.js" type="text/javascript"></script>
    <script type="text/javascript">
    // from sifr 3 site:
    var hneue = {
    src: 'themes/forturo/fonts/helvetica_neue.swf'
    ,css: {'.sIFR-root': { 'text-align': 'left', 'font-weight': 'normal', <% if menuImage = "build" %>'color': '#F77419',<% else_if menuImage = "green" %>'color': '#8fe000',<% else_if menuImage = "design" %>'color': '#0193E8',<% else %>'color': '#BEAD75', <% end_if %> 'font-size': '57px', 'z-index': '0'}}
    ,ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16],

    <% if isGalleryPage %>
    // stop flash floating over lightbox
    wmode: 'transparent'
    <% end_if %>
    };
    //sIFR.domains = ['novemberborn.net'];
    sIFR.useStyleCheck = true;
    sIFR.activate(hneue);

    sIFR.replace(hneue, {
    selector: 'h2'
    });

    </script>

    <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-56783648-1', 'auto');
    ga('send', 'pageview');

    </script>
    </head>
    <body
    <% if menuImage %>
    id="{$menuImage}"
    <% end_if %>
    class="$ClassName">
    <div id="custom-doc" class="yui-t7">
    <div id="bg">
    <div id="hd">
    <% if menuImage %>
    <img src="/themes/forturo/images/{$menuImage}-top-left.gif" alt="" id="top-left">
    <% end_if %>
    <% include AuxNavigation %>
    <% include CategoryNav %>

    </div>
    <div id="bd">
    <div class="yui-gd">
    $Layout
    </div>

    </div>
    <div id="ft"></div>
    </div><!-- /#bg -->
    </div>

    <div class="yui-t7" style="width: 76.92em; padding-bottom: 20px;">
    All content, images and designs are copyright Forturo, 2015
    </div>

    </body>
    </html>

HomePage.php

    <?php

    class HomePage extends SiteTree {

    public static $db = array(
    );

    static $has_one = array(
    'HomePageImage1' => 'Image',
    'HomePageImage2' => 'Image',
    'HomePageImage3' => 'Image',
    'HomePageImage4' => 'Image',
    'HomePageImage5' => 'Image',
    'HomePageImage6' => 'Image',
    );

    function getCMSFields() {
    $fields = parent::getCMSFields();
    // add image fields
    $fields->addFieldToTab("Root.Content.Main", new ImageField('HomePageImage1', 'Image'));
    $fields->addFieldToTab("Root.Content.Main", new ImageField('HomePageImage2', 'Image'));
    $fields->addFieldToTab("Root.Content.Main", new ImageField('HomePageImage3', 'Image'));
    $fields->addFieldToTab("Root.Content.Main", new ImageField('HomePageImage4', 'Image'));
    $fields->addFieldToTab("Root.Content.Main", new ImageField('HomePageImage5', 'Image'));
    $fields->addFieldToTab("Root.Content.Main", new ImageField('HomePageImage6', 'Image'));
    // remove content field (unused)
    $fields->removeFieldFromTab("Root.Content.Main", 'Content');
    return $fields;
    }

    }

    class HomePage_Controller extends ContentController {

    public function init() {
    parent::init();

    // Note: you should use SS template require tags inside your templates
    // instead of putting Requirements calls here.  However these are
    // included so that our older themes still work
    Requirements::themedCSS("reset-fonts-grids"); 
    Requirements::themedCSS("forturo");  
    }

    /**
    * Site search form 

    function SearchForm() {
    $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
    $fields = new FieldSet(
    new TextField("Search", "", $searchText)
    );
    $actions = new FieldSet(
    new FormAction('results', 'Search')
    );

    return new SearchForm($this, "SearchForm", $fields, $actions);
    }
    */

    /**
    * Process and render search results

    function results($data, $form){
    $data = array(
    'Results' => $form->getResults(),
    'Query' => $form->getSearchQuery(),
    'Title' => 'Search Results'
    );

    return $this->customise($data)->renderWith(array('Page_results', 'Page'));
    }
    */

    function extension(){
    return Page_Controller::extension();
    }
    }

    ?>

Page.php

    <?php

    class Page extends SiteTree {

    public static $db = array(
    );

    public static $has_one = array(
    'ContentImage' => 'Image'
    );

    public function getCMSFields(){
    $fields = parent::getCMSFields();
    $fields->addFieldToTab('Root.Content.Images', new ImageField('ContentImage', 'Content Image (appears at the top of the content)'));
    return $fields;
    }

    // menu function - is this a design page?
    function isDesign(){
    return Page_Controller::testSectionType('design');
    }

    // menu function - is this a build page?
    function isBuild(){
    return Page_Controller::testSectionType('build');
    }

    // menu function - is this an outdoor page?
    function isOutdoor(){
    return Page_Controller::testSectionType('green');
    }

    // stop aux menu items showing in main menu
    function isAuxiliary(){
    return Page_Controller::testSectionType('Auxiliary');
    }

    }

    class Page_Controller extends ContentController {

    public function init() {
    parent::init();

    // Note: you should use SS template require tags inside your templates
    // instead of putting Requirements calls here.  However these are
    // included so that our older themes still work
    Requirements::themedCSS("reset-fonts-grids"); 
    Requirements::themedCSS("forturo");     
    }


    // test which section this page lives in
    function testSectionType($sectionName){

    $sectionName = strtolower($sectionName);

    if (strtolower($this->Title) == $sectionName){
    return true;
    }

    else if(is_object($this->Parent) and isset($this->Parent->Title) and strtolower($this->Parent->Title) == $sectionName){ 
    return true;
    }
    else if (is_object($this->Parent->Parent) and isset($this->Parent->Parent->Title) and strtolower($this->Parent->Parent->Title) == $sectionName ){
    return true;
    }
    else if(is_object($this->Parent->Parent->Parent) and isset($this->Parent->Parent->Parent->Title) and strtolower($this->Parent->Parent->Parent->Title) == $sectionName){
    return true;
    }

    else{
    return false;
    }
    }

    // set menu top image ("design", "outdoor" etc)
    function menuImage(){
    $imgName = '';
    if($this->testSectionType('Design')){
    return 'design';
    }
    else if($this->testSectionType('Build')){   
    return 'build';
    }
    else if($this->testSectionType('green')){
    return 'green';
    }
    else{
    return false;
    }

    }


    function currentPage(){
    if($this->Parent->Title){
    return $this->Parent->Title;
    }
    else{
    return false;
    }
    }

    }

    ?>

PageComponant.php

    <?php
    // 'components' which are assembled into page sections at runtime
    class PageComponent extends SiteTree {

    public static $db = array(
    );

    public static $has_one = array(
    );

    // used by nav and content to see if we're processing a component (treated differently)
    function isComponent(){
    return true;
    }   
    }

    ?>

Second: The theme isn't displaying correctly.

The home page(index) should look like this https://web.archive.org/web/20140516185945/http://forturo.co.nz/ Except the photos are a slideshow

The rest of the Pages should look like https://web.archive.org/web/20140529044618/http://forturo.co.nz/photo-gallery/

css

    /* --------------------------
    Home:
    - arrows above base category links
    - colour panels in bg image
    -

    Interior
    - spash pages for sections
    - content images for int pages
    - subsection internal links for pages
    - sections for gallery page
    - design / green / build in templates
    - non category pages for aux links
    - rework contact page
    - browser testing
    ----------------------------- */

    html{
    background-color: #eee;
    }
    div#custom-doc{
    width:76.92em;
    *width:75.07em;
    min-width:1000px;
    margin:auto;
    text-align:left; 
    background: transparent url(../images/shadow.gif) bottom right repeat-y;
    margin: 0 auto;
    padding: 0 20px 20px 0;
    }

    div#bg{
    background: #323232 url(../images/forturo-main-bg.gif) top left no-repeat;
    }

    #hd img#top-left{
    float: left;
    display: inline;
    margin-left: 0;
    }

    /**
    *
    * home page
    **/
    body#home div#bg{
    background-image: url(../images/home/home-bg.gif);
    padding-bottom: 163px;

    }

    body#home img#top-stripes {
    position: relative;
    top: 12px;
    }

    body#home .design-button:hover {
    color: #0089ee;
    }

    body#home .outdoor-button:hover{
    color: #7bdb00
    }
    body#home .build-button:hover{
    color: #ff6c00;
    }

    body#home #bd div.first div{
    padding-top: 105px;
    margin-left: 128px;
    }

    body#home .yui-gd .second{
    padding-top: 0;
    position: relative;
    top: -2px;
    left: 122px;
    background-color: transparent;
    width: 858px;
    }

    body#home .yui-gd .second img#mainimage{
    display: block;
    }

    body#home img#desc{
    display: block;

    }

    /* content pages - white bg */
    .second{
    padding-top: 1px;
    overflow: hidden;
    left: 2px;
    }


    .yui-gd .second .content{
    background-color: #fff;
    min-height: 546px;
    margin-left: 10px;
    padding: 11px 10px 10px 20px;
    }

    div#pngwrap {
    position: relative;
    left: 402px;
    top: -42px;
    width: 596px;
    height: 1px;
    overflow: visible;
    text-align: right;
    }

    ul#categorynavImage {
    position: relative;
    left: -2px;
    }

    img.hide {
    display: none;
    }

    body#home img#orange, body#home img#blue, body#home img#green{
    position: relative;
    overflow: visible;
    z-index: 10;
    left: 2px;
    }

    body#home img#green, body#home img#green-button{
    left: -125px;
    }


    body#home img#blue, body#home img#blue-button{
    position: relative;
    left: -249px;
    }


    .button {
    display: block;
    float: left;
    width: 150px;
    height: 55px;
    text-indent: -9999px;
    margin-top: 84px;
    margin-right: 10px;
    position: relative;
    left: -5px;
    z-index: 11;
    }

    #textholder {
    width: 448px;
    height: 29px;
    position: relative;
    left: 141px;
    top: 10px;
    background-position: top left;
    background-repeat: no-repeat;
    }


    /* custom widths for body row */
    .yui-gd div.first{
    width: 39.75%;
    }

    .yui-gd .yui-u{
    width: 58.25%;
    }

    /*
    header
    */
    img#home-link{
    float: left;
    position: relative;
    top: -44px;
    left: 40px;
    }

    #hd img{
    display: block;
    margin-left: 619px;
    clear: left;

    }

    #hd ul li {
    display: inline;
    }

    #hd ul li a{
    color: #cccccc;
    text-decoration: none;
    font-size: 10px;
    display: block;
    float: left;
    text-transform: uppercase;
    color: #808080;
    padding: 30px 15px 0 15px;
    }


    #hd ul#aux{
    margin: 0 0 30px 632px;
    text-align: right;
    }

    #home ul#aux {
    margin-bottom: 31px;
    }

    #hd #categorynav {
    margin-left: 127px; 
    }


    #hd ul#categorynav li{
    display: inline;
    }

    #hd ul#aux li a:hover{
    background: transparent url(../images/nocat-aux-hover-bg.gif) top center no-repeat;
    color: #fff;
    }

    body#design #hd ul#aux li a:hover, body#home #hd ul#aux li a.outdoor-button:hover{
    background-image: url(../images/build-aux-hover-bg.gif);
    }

    body#green #hd ul#aux li a:hover, body#home #hd ul#aux li a.outdoor-button:hover{
    background-image: url(../images/outdoor-aux-hover-bg.gif);
    }

    body#build #hd ul#aux li a:hover, body#home #hd ul#aux li a.build-button:hover{
    background-image: url(../images/aux-hover-bg.gif);
    }

    #hd ul#categorynav{
    margin-left: 145px;
    padding-top: 20px;
    }

    #hd ul#categorynav li{
    padding-right: 30px;
    }

    #hd ul#categorynav li a{
    font-size: 14px;
    text-transform: uppercase;
    color: #808080;
    }


    /* section and hover states */
    #hd ul#categorynav li a#hdr-design:hover, body#design #hd ul#categorynav li a#hdr-design{
    color: #0193e8;
    }

    body#build #hd ul#categorynav li a#hdr-build, #hd ul#categorynav li a#hdr-build:hover{
    color: #f77419;
    }

    body#green #hd ul#categorynav li a#hdr-outdoor, #hd ul#categorynav li a#hdr-outdoor:hover{
    color: #97ce00;
    }


    h1{
    text-indent: -9999px;
    height: 1px;
    }


    /* body row */
    .yui-gd{
    margin-top: 12px;
    }

    /**
    * nav
    **/ 
    #bd .yui-gd .nav div{
    margin-top: 37px;
    margin-left: 136px;
    }

    #bd .yui-gd .nav ul{
    min-height: 234px;
    margin-top: 12px;
    width: 278px;
    background: transparent url(../images/nav-bg.gif) top left no-repeat;
    padding-top: 4px;
    }

    #bd .yui-gd .nav ul li{
    background: transparent url(../images/nav-bg.gif) bottom left no-repeat;
    padding: 1px 0 6.75px 15px;
    }

    #bd .yui-gd .nav ul li a{
    color: #92928f;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 85%;
    }


    /* nested nav */
    #bd .yui-gd .nav ul li ul{
    background-color: transparent;
    background-image: none;
    min-height: 10px;
    margin-top: 0;
    width: 272px;
    position: relative;
    left: -13px;        
    }

    #bd .yui-gd .nav ul li ul li{
    padding: 6.75px 0 1px 23px;
    background-position: top left;
    }

    #bd .yui-gd .nav ul li ul li a{
    background: transparent url(../images/nav-indicator.gif) 0 5px no-repeat;
    padding: 2px 2px 2px 10px;
    display: block;
    color: #fff;
    }

    #bd .yui-gd .nav ul li ul li a:hover{
    background-image: url(../images/nav-indicator-active.gif);  
    }

    body#design #bd .yui-gd .nav ul li ul li a:hover{
    background-image: url(../images/nav-indicator-design-active.gif);   
    }


    /* link hover - sections */
    body#green #bd .yui-gd .nav ul li a:hover{
    color: #97ce00;
    }

    body#build #bd .yui-gd .nav ul li a:hover{
    color: #f77419;
    }

    body#design #bd .yui-gd .nav ul li a:hover{
    color: #0193e8;
    }


    #bd .yui-gd .nav img#latest-news {
    position: relative;
    left: 5px;
    margin-top: 25px;
    }


    #bd .yui-gd .nav img#phone-number {
    position: relative;
    left: -120px;
    top: -22px;
    }

    img#categoryimage {
    margin-top: -80px;
    position: relative;
    left: -119px;
    top: -29px;
    }


    /* ---------------------------
    content area
    ------------------------------ */
    .content h2{
    font-size: 47px;
    font-weight: normal;
    color: #f88635;
    margin-top: 19px;
    background: #fff url(../images/dots.gif) bottom right no-repeat;
    position: relative;
    left: 13px;
    margin-left: -13px;
    }

    .content strong {
    font-weight: bold;
    }

    .content h2 + img {
    display: block;
    margin-top: 10px;
    position: relative;
    left: 1px;
    }

    /* header colous for each section */
    body#build .content h2{ color: #0193e8;}

    body#green .content h2{
    color: #97ce00;
    }


    div.backtotop{
    margin-top: 20px;
    background: #fff url(../images/backtotop-bg.gif) center right no-repeat;
    position: relative;
    left: 14px;
    }

    div.backtotop a{
    color: #808080;
    font-weight: bold;
    text-decoration: none;
    font-size: 90%;
    padding-left: 15px;
    background: #fff url(../images/backtotop-arrow.gif) center left no-repeat;
    position: relative;
    left: -14px;
    }

    div.backtotop a:hover{
    color: #3f3f3f;
    }

    /* general text styles */
    .content *{
    font-family: trebuchet, "trebuchet MS", helvetica, sans-serif;
    color: #3b3b3b;
    }

    .content p{
    margin: 10px 0;
    }

    .content .text, .content textarea {
    margin-bottom: 10px;
    width: 200px;
    }

    .content h4{
    font-weight: bold;
    text-transform: uppercase;
    }


    /* ---------------------------
    gallery pages
    ------------------------------ */
    .gallery strong{
    font-weight: normal;
    }

    body#design .gallery strong {
    color: #0193e8;
    }

    body#build .gallery strong {
    color: #F77419;
    }

    body#green .gallery strong {
    color: #8fe000;
    }

    .gallery #ImageGallery table td {
    padding: 0 16px 16px 0;
    }

    /* ----------------------------
    blog
    ----------------------------- */
    h4 a{text-decoration: none}
    h4 a:hover{text-decoration: underline}
    span.authorDate{
    color: #FFBE8F;
    }


    p#copyright {
    width: 1000px;
    text-align: left;
    }


    /*
    * filters
    **/

    /* webkit */
    @media screen and (-webkit-min-device-pixel-ratio:0){
    /* shift content area right a touch */
    .yui-gd .second{
    position: relative;
    left: 2px;
    }

    /* shift home rollover images left 1px each*/

    }

    /* opera 9.5+ */
    @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {
    /* home - rotating images and floating png's */
    :root body#home .yui-gd .second{
    left: 6px; top: 12px;
    }

    :root body#home img#top-stripes{
    top: 26px;
    }

    :root .yui-gd .second{
    position: relative;
    left: 11px;
    }

    }

    /* ie 7 */

    /* stop nav dropping down */
    * + html #bd .yui-gd .nav ul, * + html #bd .yui-gd .nav ul li ul{
    width: 262px;
    }

    * + html div.backtotop {
    left: 12px;
    }

Hopefully someone can help me out, thank you in advance

  • 写回答

2条回答 默认 最新

  • douju4278 2015-01-24 21:29
    关注

    2.4 to 3.1 is a pretty big jump in terms of compatibility... did you read over the upgrading guides? Going over the 2.4 -> 3.0 guide first might be useful. http://docs.silverstripe.org/en/3.0/changelogs/3.0.0/

    Also unsure what this is doing...

    function extension(){
        return Page_Controller::extension();
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)