denyadzi/luya-module-posts

该模块提供标准的博客/新闻功能,包括分类、文章、标签、wysiwyg,以及社交网络集成。

安装: 139

依赖: 0

建议: 0

安全: 0

星标: 5

关注者: 2

分支: 1

开放问题: 2

类型:luya-module

dev-master / 2.x-dev 2020-02-27 06:08 UTC

README

LUYA Logo

帖子模块

LUYA Slack Support

该模块提供标准的博客/新闻功能,包括分类、文章、标签、wysiwyg,以及社交网络集成。

此模块是 luya 新闻模块 的分支。

稳定性

该模块处于开发中,因此目前尚无稳定版本。

安装

安装模块需要Composer。

composer require denyadzi/luya-module-posts: ~2.0-dev

对于多语言帖子,强烈建议在您的系统中安装php intl 扩展。

配置

通过Composer安装后,在配置文件中的模块部分包含该模块。

'modules' => [
    // ...
    'posts' => [
    	'class' => 'luya\posts\frontend\Module',
    	'useAppViewPath' => false, // When enabled the views will be looked up in the @app/views folder, otherwise the views shipped with the module will be used.
    ],
    'postsadmin' => [
        'class' => 'luya\posts\admin\Module',
        'vkAppId' => 1234, /* optional. Needed for Vkontakte autoposts */
        'fbAppId' => 1234, /* optional. Needed for Facebook autoposts */
        'wysiwygOptions' => [ /* various tinymce editor options */
            'height' => '480',
            'menubar' => false,
            'plugins' => 'link image code lists textcolor',
            'toolbar' => 'undo redo | bold underline italic forecolor backcolor image | alignleft aligncenter alignright alignjustify | numlist bullist outdent indent | removeformat | code'
        ],
    ],
]

初始化

成功安装和配置后,运行迁移、导入和设置命令以在项目中初始化模块。

1.) 迁移数据库。

./vendor/bin/luya migrate

2.) 将模块和迁移导入到您的LUYA项目中。

./vendor/bin/luya import

添加权限到您的组后,您将能够编辑和添加新的帖子。

示例视图

由于该模块会尝试渲染帖子概览的视图,以下是一个非常基本的示例

views/posts/default/index.php

<?php
use yii\widgets\LinkPager;

/* @var $this \luya\web\View */
/* @var $provider \yii\data\ActiveDataProvider */
?>
<h2>Latest Posts</h2>
<?php foreach($provider->models as $item): ?>
    <?php /* @var $item \luya\posts\models\Article */ ?>
    <pre>
        <?php print_r($item->toArray()); ?>
    </pre>
    <p>
        <a href="<?= $item->detailUrl; ?>">Post Detail Link</a>
    </p>
<?php endforeach; ?>

<?= LinkPager::widget(['pagination' => $provider->pagination]); ?>

views/posts/default/detail.php

<?php
/* @var $this \luya\web\View */
/* @var $model \luya\posts\models\Article */
?>
<h1><?= $model->title; ?></h1>
<pre>
<?php print_r($model->toArray()); ?>
</pre>

上述示例将仅输出模型活动记录中的所有数据。