laravel cms_推出OctoberCMS-基于Laravel的CMS

laravel cms

October CMS is a lightweight, back to basics content management system built on Laravel, and on a mission to make your web development workflow easy again. It boasts a very simple and fast learning curve, with a guarantee that you’ll be off the ground and up and running in no time at all. It’s scalable and extensible through the plugin system, is easily maintainable through its file-based system, and allows for the effortless creation of administrative back-end interfaces. Before we dig a bit deeper into this promising CMS, let’s look at the foundation a bit.

October CMS是基于Laravel构建的轻量级,回归基础的内容管理系统,其使命是使您的Web开发工作流程再次变得轻松。 它具有非常简单和快速的学习曲线,可确保您立即动手起来并开始运行。 它可以通过插件系统进行扩展和扩展,可以通过基于文件的系统轻松维护,并且可以轻松创建管理后端接口。 在深入研究这个有前途的CMS之前,让我们先看一下基础。

october

基于Laravel PHP框架构建 (Built On Laravel PHP Framework)

The Laravel PHP framework is lightweight, sturdy, and elegant. According to them, it’s a framework built with a creative user in mind, transforming mundane tasks into effortless, enjoyable ones. The philosophies of both Laravel and October CMS coincide very nicely, and it’s no surprise to see that October has gone with this type of framework. The combination provides the perfect mesh of simplicity, speed, elegance, and artisanal-style programming. Let’s now take a look at setting up our first October CMS project.

Laravel PHP框架轻巧,坚固且优雅。 根据他们的说法,这是一个构想成创意的用户构建的框架,可将平凡的任务转变为轻松,愉快的任务。 Laravel和October CMS的理念非常吻合,毫不奇怪的是,十月采用了这种类型的框架。 这种结合提供了简单,快速,优雅和手工风格编程的完美结合。 现在让我们看一下设置我们的第一个十月CMS项目。

立即开始 (Get Started In No Time)

October makes installation a breeze for us. The following steps will set you on course for development:

十月使我们的安装变得轻而易举。 以下步骤将使您踏上发展的道路:

  1. Either clone their repo on GitHub, or download the installer. The recommended way is to download the installer, as it’s simple and quick, and allows you to make some configurations right inside the browser in an easy-to-follow stepwise interface.

    可以在GitHub上克隆其仓库,或者下载安装程序 。 推荐的方法是下载安装程序,因为它既简单又快速,并且允许您在浏览器中通过易于遵循的逐步界面进行一些配置。

  2. Extract the files into your desired local directory, and configure your local server to match the local path.

    将文件提取到所需的本地目录中,然后配置本地服务器以匹配本地路径。
  3. Set up a new database, and take note of the database name.

    设置一个新的数据库,并记下数据库名称。
  4. Navigate to the install.php file in your browser, follow the instructions on screen, and enter your configuration variables.

    在浏览器中导航至install.php文件,按照屏幕上的说明进行操作,然后输入配置变量。

As prompted, delete the install files after successful installation, and you’ll be ready to go. You can now navigate to your site’s front end, and explore the admin area too. Let’s dig in to the inner workings of October CMS.

根据提示,在成功安装后删除安装文件,即可开始使用。 现在,您可以导航到站点的前端,并浏览管理区域。 让我们深入研究October CMS的内部工作原理。

全部运作方式–主题和模板 (How It All Works – Themes & Templates)

The theme directory is the foundation for the end-output of any new October CMS installation. This directory contains all the sub-directories and files necessary for the CMS to tick. By default, October CMS kicks you off with a demo theme. Creating your own is as easy as creating a new directory (name it whatever you want), a theme configuration file called theme.yaml in the root of this directory, and a pages directory with a page file in it. For now, let’s explore the demo theme to get a grasp of the inner workings.

主题目录是任何新的October CMS安装的最终输出的基础。 该目录包含CMS打勾所需的所有子目录和文件。 默认情况下,十月CMS以演示主题开始。 创建自己的目录就像创建一个新目录( theme.yaml命名),在该目录的根目录中创建名为theme.yaml的主题配置文件theme.yaml在其中包含页面文件的页面目录一样容易。 现在,让我们探索演示主题以了解内部工作原理。

Every theme consists of sub-directories for pages, partials, layouts, content files, and assets. Each of these directories may contain sub-directories, allowing for simplification of larger scale projects. Here’s what the demo directory structure looks like:

每个主题均包含页面,部分,布局,内容文件和资产的子目录。 这些目录中的每个目录都可以包含子目录,从而可以简化大型项目。 演示目录结构如下所示:

themes/
  demo/
    assets/
      css/
      images/
      javascript/
      ...
    content/
    layouts/
    pages/
    partials/
    theme.yaml

Template files take on a simple structure, and make use of Twig markup. Twig is a PHP templating engine, enhancing and speeding up templating, and reducing common verbose tasks to simple code snippets. There are three parts to any of the page, layout, and partial template files:

模板文件采用简单的结构,并使用Twig标记 。 Twig是一个PHP模板引擎,可增强和加速模板,并将常见的繁琐任务简化为简单的代码片段。 页面,布局和部分模板文件包含三个部分:

  1. Configuration

    组态
  2. PHP code

    PHP代码
  3. Twig markup

    树枝标记

The configuration section is structured like a php.ini file, and is marked as finished by two = symbols, making way for the PHP section. The PHP section is optional for any template file, and is also marked as finished by typing two more = symbols. Finally, the Twig markup contains the actual contents of the template file. This is what a template file might look like, taken from their website:

配置节的结构类似于php.ini文件,并用两个=符号标记为完成,为PHP节腾出了空间。 PHP部分对于任何模板文件都是可选的,并且通过输入两个=符号将其标记为完成。 最后,Twig标记包含模板文件的实际内容。 这是从其网站上获取的模板文件的外观:

url = "/blog"
layout = "default"
==
function onStart()
{
  $this['posts'] = ...;
}
==
<h3>Blog archive</h3>
{% for post in posts %}
  <h4>{{ post.title }}</h4>
  {{ post.content }}
{% endfor %}

Let’s look a bit more into what purpose each template file and section serves.

让我们再看一下每个模板文件和部分的用途。

页数 (Pages)

Page files have a self-explanatory title – they describe your site’s pages. They take on three parameters in the configuration section:

页面文件具有不解释的标题-它们描述了您网站的页面。 它们在配置部分采用三个参数:

  1. url – the page url (required)

    url –页面URL(必填)

  2. title – the page title (required)

    title –页面标题(必填)

  3. layout – the page layout, which may point to a layout file (optional)

    layout –页面版式,可能指向版式文件(可选)

  4. description – the description for the page in the back-end (optional)

    description后端中页面的描述(可选)

The page url can take on parameters, depending on the page in question. 404 and error pages can also be specified. Here’s a simple example of a page layout:

页面URL可以带有参数,具体取决于所讨论的页面。 还可以指定404和错误页面。 这是页面布局的一个简单示例:

url = "/"
title = "Welcome"
description = "The home page."
==
<h1>Welcome Home</h1>

You can read up more on pages here.

您可以在此处阅读更多内容。

部分 (Partials)

Partials also have a fairly self-explanatory name – they refer to files that contain partial amounts of code. Partial files are powerful, because they can be called and reused in pages, layouts, or other partials. You can use the {% partial %} tag to call a partial from inside another file. Partials only support one configuration parameter:

部分文件也有一个不言自明的名称-它们引用包含部分代码量的文件。 局部文件功能强大,因为它们可以在页面,布局或其他局部文件中调用和重用。 您可以使用{% partial %}标记从另一个文件内部调用部分。 部分仅支持一个配置参数:

  1. description – the partial description for the back-end (optional)

    description –后端的部分描述(可选)

Here’s a basic example of a partial (right sidebar) calling another partial (recent posts):

这是一个局部(右侧边栏)调用另一个局部(最近的帖子)的基本示例:

description = "Right sidebar."
==
<div class="sidebar">
  <aside>
    {% partial "recent-posts" %}
  </aside>
</div>

You can read up on partials here.

您可以在此处阅读偏读。

版面 (Layouts)

Layout files specify the layout of a page, following suit with the self-explanatory nature of the first two template file types we looked at. They act as the major building blocks for any October CMS project. They take on two configuration options, both of which are used in the back-end interface:

布局文件指定页面的布局,这与我们看过的前两种模板文件类型的不言而喻的性质相适应。 它们是任何十月CMS项目的主要构建块。 它们具有两个配置选项,这两个选项都在后端接口中使用:

  1. name – the name of the layout file for the back-end (optional)

    name –后端的布局文件的名称(可选)

  2. description – the layout file description for the back-end (optional)

    description后端的布局文件描述(可选)

A layout page might look something like this:

布局页面可能看起来像这样:

name = "Default"
description = "The default layout for our template"
==
<!doctype html>
<html>
  <body>
    {% page %}
  </body>
</html>

Let’s assume that we named this layout file default.htm and placed it in our layouts directory. A page can then call on this layout like this:

假设我们将此布局文件命名为default.htm ,并将其放置在layouts目录中。 然后页面可以像这样调用此布局:

title = "Welcome"
url = "/"
layout = "default"
description = "Welcome home!"
==
<h2>Welcome Home!</h2>
<p>...</p>

Pretty neat! More on layouts here.

漂亮整齐! 更多关于这里的布局。

内容块 (Content Blocks)

Content files contain content sections, and can be called from inside layout, page, or partial files. Content files support three extensions:

内容文件包含内容部分,并且可以从布局,页面或部分文件内部调用。 内容文件支持三个扩展名:

  1. .htm (for HTML markup)

    .htm(用于HTML标记)
  2. .txt (for plain text)

    .txt(用于纯文本)
  3. .md (for markdown) <- awesome

    .md(用于markdown)<-很棒

You can call a content file using twig markup by running the {% content %} tag. Here’s an example of a page rendering a couple of content blocks:

您可以通过运行{% content %}标签来使用树枝标记来调用内容文件。 这是一个呈现几个内容块的页面示例:

<div class="sidebar">
  <aside class="recent-posts">
    {% content "einstein-quote.htm" %}
  </aside>
  <aside class="newsletter">
    {% content "newsletter.htm" %}
  </aside>
</div>

Check out more about content files here.

在此处查看有关内容文件的更多信息。

AJAX模块 (AJAX Module)

October CMS has a very robust AJAX framework built in, allowing you to make AJAX requests and interact with a number of data attributes very easily. To add the AJAX framework, simply include it by placing the {% framework %} tag anywhere inside the page or layout in question. It requires jQuery (which should be loaded before the framework), so your page might look like this:

October CMS内置了一个非常健壮的AJAX框架,使您可以发出AJAX请求并非常轻松地与许多数据属性进行交互。 要添加AJAX框架,只需将{% framework %}标签放置在相关页面或布局内的任何位置即可。 它需要jQuery(应该在框架之前加载),因此您的页面可能如下所示:

<script src="{{ [
    'assets/js/jquery.min.js',
]|theme }}"></script> 
 
{% framework %}

AJAX requests work by invoking an event handler on the server. This event handler can then update page elements using partials. There are two API’s at our disposal for performing AJAX tasks:

AJAX通过在服务器上调用事件处理程序来请求工作。 然后,此事件处理程序可以使用partials更新页面元素。 我们可以使用两种API来执行AJAX任务:

数据属性API (The Data Attributes API)

This API lets you issue AJAX requests without any JavaScript (less verbose than the JavaScript API). Here’s an example from their website using the Data Attributes API. It redirects a user to another page after a successful request:

使用此API,您无需任何JavaScript(比JavaScript API冗长得多)即可发出AJAX请求。 这是他们网站上使用Data Attributes API的示例。 成功请求后,它将用户重定向到另一个页面:

<form data-request="onLogin" data-request-redirect="/admin">

Easy and efficient. The only shortcoming I can see here so far is the limited list of data-attributes at our disposal. However, the JavaScript API offers a more powerful option.

简单高效。 到目前为止,我在这里看到的唯一缺点是可供我们使用的数据属性列表有限。 但是,JavaScript API提供了更强大的选项。

JavaScript API (The JavaScript API)

This API is more powerful than the data attributes API, as it allows us to use any options and methods compatible with the jQuery AJAX function. We can use the request() method with any element inside a form, or on the form itself. The request() method has a single required parameter – the handler name. Here’s an example:

该API比数据属性API更强大,因为它允许我们使用与jQuery AJAX函数兼容的任何选项和方法。 我们可以将request()方法与表单内部或表单本身上的任何元素一起使用。 request()方法有一个必需的参数-处理程序名称。 这是一个例子:

<form onsubmit="$(this).request('onProcess'); return false;">

With this method, we gain a lot more flexibility and control. For more on the AJAX module, check out the docs here.

使用这种方法,我们可以获得更多的灵活性和控制力。 有关AJAX模块的更多信息,请在此处查看文档。

易于扩展 (Easy Extensibility)

October CMS is easily extendable via plugins and components. According to the documentation:

十月CMS可通过插件和组件轻松扩展。 根据文档:

Plugins are the foundation for adding new features to the CMS by extending it…Components are building blocks that can be attached to any page or layout.

插件是通过扩展CMS向其添加新功能的基础……组件是可以附加到任何页面或布局的构建基块。

Let’s take a look at each of these features in detail.

让我们详细了解这些功能。

外挂程式 (Plugins)

Plugins are the basis of extending October CMS beyond out of the box functionality. They can define components, add back-end pages, interact and edit the functionality of other plugins, among other things. They are easily described and set up, and reside in the /plugins directory. To get started with plugin development, visit the plugin docs, or stay tuned for an upcoming tutorial on SitePoint in a day or two.

插件是扩展October CMS功能的基础。 他们可以定义组件,添加后端页面,交互和编辑其他插件的功能等。 它们易于描述和设置,并位于/plugins目录中。 要开始进行插件开发,请访问插件docs ,或在两到两天内关注SitePoint上即将发布的教程。

组件 (Components)

Components provide us with configurable building blocks, and they can be attached to any page, partial, or layout. They extend the behaviour of front-end pages by:

组件为我们提供了可配置的构建基块,它们可以附加到任何页面,部分页面或布局。 它们通过以下方式扩展了前端页面的行为:

  1. Injecting variables by participating in the page execution cycle

    通过参与页面执行周期来注入变量
  2. Handling AJAX events triggered by the page

    处理页面触发的AJAX事件
  3. Providing basic markup using partials

    使用局部函数提供基本标记

To read up more on components, check up on the documentation here.

要阅读有关组件的更多信息,请查阅此处的文档。

结语 (Wrap Up)

October CMS’s very own philosophy is represented throughout their documentation. Getting started is an extremely simple process, making you feel comfortable with the CMS off the bat. The two guys behind it, Alexey Bobkov and Samuel Georges, are dead set on making web development and deployment simple, and that for me is a huge attribute to this project.

在整个文档中都代表着October CMS自己的理念。 入门是一个非常简单的过程,可让您轻松使用CMS。 背后的两个人Alexey Bobkov和Samuel Georges都对简化Web开发和部署持坚定态度,这对我来说是这个项目的重要因素。

If I could find one single thing to dislike about it, it would be that the AJAX framework is jQuery dependent. That’s not to say that it’s not sturdy and highly functional – in fact I personally think the jQuery AJAX function is awesome. In any case, you shouldn’t have much of a problem implementing your own set of JS should you desire. Other than that, I’m really excited about this CMS, and am already planning to use it in an upcoming project.

如果我发现不喜欢它的一件事,那就是AJAX框架是jQuery依赖的。 这并不是说它不坚固且功能强大–实际上,我个人认为jQuery AJAX函数很棒。 无论如何,如果您愿意,实现自己的JS集不会有太大问题。 除此之外,我对此CMS感到非常兴奋,并且已经计划在即将到来的项目中使用它。

翻译自: https://www.sitepoint.com/introducing-octobercms-laravel-based-cms/

laravel cms

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值