Git Product home page Git Product logo

luya-module-news's Introduction

LUYA Logo

News Module

LUYA Latest Stable Version Tests Maintainability Test Coverage Total Downloads

The news module will provided you a basic news system with categories and tags.

Installation

For the installation of modules Composer is required.

composer require luyadev/luya-module-news

Configuration

After installation via Composer include the module to your configuration file within the modules section.

'modules' => [
    // ...
    'news' => [
    	'class' => 'luya\news\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.
    ],
    'newsadmin' => 'luya\news\admin\Module',
]

Initialization

After successfully installation and configuration run the migrate, import and setup command to initialize the module in your project.

1.) Migrate your database.

./vendor/bin/luya migrate

2.) Import the module and migrations into your LUYA project.

./vendor/bin/luya import

3.) Add the permissions to your group (Under "System -> Groups" in the LUYA admin interface)

You will now be able to edit and add news articles.

With version 2.0 of news module, the admin queue is required in order to switch the visibility of the news based on time, therefore read LUYA Queue or enable:

'modules' => [
    'admin' => [
        'class' => 'luya\admin\Module',
        // ...
        'autoBootstrapQueue' => true,
    ],
    //...
]

Example Views

As the module will try to render a view for the news overview, here is what this could look like this in a very basic way:

views/news/default/index.php

<?php
use yii\widgets\LinkPager;

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

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

views/news/default/detail.php

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

The above examples will just dump all the data from the model active records.

luya-module-news's People

Contributors

agaplus avatar andregm avatar asyou99 avatar cebe avatar dennisgon avatar dev7ch avatar emericanec avatar hbugdoll avatar jdl747 avatar johnnymcweed avatar martinpetrasch avatar nadar avatar nandes2062 avatar ph0tonic avatar rodzadra avatar rolandschaub avatar samdark avatar testt23 avatar themaaarc avatar trk avatar vavepl avatar vuongxuongminh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

luya-module-news's Issues

LinkPager

I think that linkpager does not work correctly because the links on the buttons are generated from the controller and contain the name "cms/default/index", and should probably generate from the "URL Path segment" where we set when adding a new page. For testing, I set the route in pagination on "news" and its works.

  1. Default generated link
    linkpager1
  2. When I opened
    linkpager3
  3. Set route to "news"
    linkpager5
  4. Generated link after setting route to "news"
    linkpager6

Feature request: search news/article on frontend page

hello, Luya is very good I love it. I think there are features that should exist. maybe, features like frontend search, for searching news/article title, news/article category, and news/article with specific tags.

License is missing

License is missing... maybe MIT License like the LUYA main modules.

All LUYA modules should have a LICENSE.md.

Admin Menu Item

Hi, after installing this module, the menu item for news is not appearing at the admin sidebar like shown in the demo (block is showing though). Is this normal?

New Fields

  • new field for a "link", this can be external or internal, type link
  • new field for "author" as text. a getter method will either return the plain text from "author" field or if empty will return the firstname and lastname from the created_by user id

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.