php - concrete5中主题的目录结构

标签 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 include 来引用主题中的目录吗?例如,在 default.php 中,你可以有类似 <?php require_once echo $this->getThemePath() . "/includes/footer.html"; ?> 的东西吗? ?
  • 是否echo $this->getThemePath()用于子目录中的文件(例如 my-theme/includes/footer.php)时引用正确的主题文件夹?

最佳答案

简而言之:您可以按照自己想要的方式构建主题 map 。 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

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

请注意 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')
    );
    }
}
?>

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

关于php - concrete5中主题的目录结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27491480/

相关文章:

git - 如何从 git 存储库中删除外部空文件夹?

mysql - Concrete5 SQLSTATE[HY000] [2002] 本地主机上没有这样的文件或目录

php - 这是PHP中的错误吗

php - 通过 css 根据输入的 id 或标题显示图像

具有 C 扩展的 Python 项目 - 结构、导入和测试

c++ - 当有许多项目相互依赖时,Visual C++ 中的文件夹结构

php - 根据从 MySQL 检索的数据填充 HTML 表头

php - 如何清空属于关联数组的键的内容而不取消 PHP 中的键设置?

php - 在我的本地主机上安装crete5时出现SQL错误

ubuntu - 在 Ubuntu 'Jaunty' 上构建 GD 的问题