具体的主题目录结构5

时间:2014-12-15 19:19:48

标签: php directory-structure concrete5

从我在互联网上收集到的,部分来自文档的内容是建议采用如下主题结构。

/css
/fonts
/img
/includes
/js
/default.php
/main.css
/thumbnail.png
/typography.css
/view.php

我的问题是:

  • main.csstypography.css可以驻留在/css吗?我喜欢整齐排列的css
  • 你能使用PHP包括引用主题中的目录吗?例如,在default.php中,您可以使用<?php require_once echo $this->getThemePath() . "/includes/footer.html"; ?>吗?
  • echo $this->getThemePath()在子目录中的文件(例如my-theme/includes/footer.php)上使用时是否引用了正确的主题文件夹?

1 个答案:

答案 0 :(得分:2)

简而言之:您可以按照您希望的方式构建主题地图。除了default.php,view.php,description.txt和thumbnail.png。可以更改typography.css的名称和位置,但我只找到了5.6版的源代码。在版本5.7中,typography.css不再使用,因为所见即所得的编辑器已经改变。但是,您可以将自定义样式添加到新的WYSIWYG编辑器中。

完整答案
示例主题目录:

css (css folder)
js (javascript folder)
img (or images)
elements (php files that I want to include)
view.php
default.php
thumbnail.png
description.txt

thumbnail.png,description.txt,view.php(对于单个页面)和default.php需要直接在主题目录下。

在元素地图中,我创建了一个header.php和footer.php(但是如果必要的话你可以在那里添加更多的文件,比如sidebar.php或类似的东西)
要链接到header.php和footer.php,我将此代码放在default.php和view.php中的正确行:

//version 5.6 and below
$this->inc('elements/header.php');
$this->inc('elements/footer.php');

//version 5.7 and higher
$view->inc('elements/header.php');
$view->inc('elements/footer.php');

concrete5中的inc()函数专门用于包含项目,这就是为什么我更喜欢使用它而不是php的普通包含函数。以下是default.php的示例:http://pastie.org/9784547

在我的header.php和/或footer.php中,您需要添加自定义css和js。为此,您可以使用以下代码:

//version 5.6 and below
<link rel="stylesheet" media="screen" type="text/css" href="<?php echo $this->getThemePath() ?>/css/main.css" />
<?php echo '<script src="'.$this->getThemePath().'/js/concrete.js"></script>'; ?>

//version 5.7 and higher
<link rel="stylesheet" media="screen" type="text/css" href="<?php echo $view->getThemePath() ?>/css/main.css" />
<?php echo '<script src="'.$view->getThemePath().'/js/concrete.js"></script>'; ?>

header.php示例:http://pastie.org/9784546

请注意,header.php上尚未添加typography.css。

typography.css会自动加载到系统中,以便在wysiwyg编辑器中使用。要更改typography.css的名称和位置,您必须覆盖getThemeEditorCSS()函数。
仅适用于版本5.6 如何:http://concrete5tricks.com/blog/rename-or-move-typography-css

如果您使用的是版本5.7
在主题文件夹的根目录中创建一个page-theme.php文件 要定义自定义样式,请添加到page-theme.php:

<?php
namespace Application\Theme\Your_Theme_Name;
class PageTheme extends \Concrete\Core\Page\Theme\Theme {
    public function getThemeEditorClasses(){
    return array(
        array('title' => t('Title Thin'), 'menuClass' => 'title-thin', 'spanClass' => 'title-thin'),
        array('title' => t('Title Caps Bold'), 'menuClass' => 'title-caps-bold', 'spanClass' => 'title-caps-bold'),
        array('title' => t('Title Caps'), 'menuClass' => 'title-caps', 'spanClass' => 'title-caps')
    );
    }
}
?>

(不要忘记在添加样式后更改主题名称中的Your_theme_Name +清除缓存)
资料来源:http://www.concrete5.org/community/forums/5-7-discussion/adding-redactor-custom-styles-in-a-theme/