Articles

Usage

The articles can be used when creating a blog or news section for your website.

Fields

Title & Content

The title, content and meta description fields are translatable so if your website is available in more than one language you will see flag icons at the top of the page. Clicking a flag will switch to the tab that contains fields for the selected language. The "title" and "content" fields are required (in all languages).

Translations are possible thanks to the spatie/laravel-translatable package.

The "meta description" field can be connected to the "description" meta tag in the front-end:

<meta name="description" content="{{ $article->meta_desc }}">

Custom URL

Each article must have a unique custom "SEF URL" (search friendly url or custom url). So for example if your website is available at https://mysite.com and you have entered "my_article" for a custom url your visitors can access it on this address: https://mysite.com/my_article

Search engine friendly URLs thanks to the taffovelikoff/laravel-sef package.

Image attachments

If you prefer you can disable the file manager from the WYSIWYG editor and use the "Attach Images" field. This way you can specify in the templates exactly where and how the images should be displayed. The WYSIWYG editor gives the admin the option to place any image anywhere in the content, but say you want to have a header image or maybe place a few images in a carousel for example, then it's better to use the "Attach Images" field. Here is an example of how to display a carousel in the front-end using the attached images:

<div id="carouselExampleSlidesOnly" class="carousel slide" data-ride="carousel">
    @foreach($article->attachmentsGroup('images') as $image)
        <div class="carousel-inner">
            <div class="carousel-item active">
                <img class="d-block w-100" src="{{ $image->filepath }}">
            </div>
        </div>
    @endforeach
</div>

With the thumbnail() helper function you can generate a thumbnail with custom dimensions. You can use CSS to resize the image in the front-end, but thumbnail() will create a cached version of the image with the given dimensions, hence speeding up the loading time for the page. You can learn more about the function in the "Helpers" section of this documentation.

{{ thumbnail($image->filepath, '500x500') }}

Attachments are available thanks to the bnbwebexpertise/laravel-attachments package.

Tags

You can tag articles. This gives you some additional functionalities:

use TaffoVelikoff\HotCoffee\Article;
...
$article = Article::find(1); // get article with id 1

$article->tagNames(); // get array of related tag names

Article::withAnyTag(['Gardening','Cooking'])->get(); // fetch articles with any tag listed

Article::withAllTags(['Gardening', 'Cooking'])->get(); // only fetch articles with all the tags

Article::withoutTags(['Gardening', 'Cooking'])->get(); // only fetch articles without all tags listed

Article::existingTags(); // return collection of all existing tags on any articles

Tagging is possible thanks to the rtconner/laravel-tagging package.

TinyMCE

TinyMCE is used as the WYSIWYG editor for the content field. You can easily change text color, size and fonts, add multimedia and much more. You can also link resources directly from the "File Manager" module.

Last updated