具体的主题目录结构5

Bra*_*roy 5 php directory-structure concrete5

从我在互联网上收集的内容和部分来自文档的内容来看,建议使用如下主题结构.

/css
/fonts
/img
/includes
/js
/default.php
/main.css
/thumbnail.png
/typography.css
/view.php
Run Code Online (Sandbox Code Playgroud)

我的问题是:

  • 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)中的文件上使用时是否引用正确的主题文件夹?

Joz*_*zeh 2

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

完整答案
示例主题目录:

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
Run Code Online (Sandbox Code Playgroud)

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');
Run Code Online (Sandbox Code Playgroud)

crete5 中的 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>'; ?>
Run Code Online (Sandbox Code Playgroud)

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

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

typography.css 会自动加载到系统中以在所见即所得编辑器中使用。要更改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')
    );
    }
}
?>
Run Code Online (Sandbox Code Playgroud)

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