Print
Category: Tutorials
Hits: 3115
26Mar2023

Use a Latest News Enhanced Pro blog view as feed for another website

Information
First published February 26, 2021
3115 hits - No rating

In this tutorial, learn how you can create a feed from a Latest News Enhanced Pro blog view and use that feed on another website with core Joomla or the Newsfeeds plugin for Latest News Enhanced Pro.

For this tutorial, you need:

Optional:

Step 1 - Site source - Set global parameters

In the Joomla admininstrator console, go to System -> Global Configuration -> Latest News Enhanced Pro.
Go to the Integration tab.
Set 'Show feed link' to 'Show'.
You have the ability to include custom fields (or K2 extra fields) into the feed with the 'Include fields' parameter.

Set global settings
Set global settings

There are 2 options when including fields:

As HTML code

<description><![CDATA[<dl class="fields"><dt>Age Group</dt><dd>21 - 30</dd><dd>31 - 60</dd></dl>This is a sample blog posting 3. If you log in to...]]></description>

The feed item <description> element contains the fields in the <dl> HTML tag, before the regular content.

As syntax

<description><![CDATA[{field alias=[agegroup] name=[Age Group]}21 - 30,31 - 60{/field}This is a sample blog posting 3. If you log in to...]]></description>

The feed item <description> element contains the fields in a {field}{/field} plugin syntax, before the regular content.

You can set those parameters globally but change them for each blog view you create. You will find the same options under the Integration tab for each view.

Note on the option 'As syntax'.

You would select the 'As syntax' option in the event you would have a plugin on the receiving end (where the feed is read) that could interpret it. This could be any custom made plugin, or, if you are using Latest News Enhanced Pro on that target site, the plugin 'Newsfeeds', which can parse it.

Step 2 - Site source - Create a blog view

Go to Menus -> [your menu of choice] -> Add new menu item and create a menu item of type Blog (for core Joomla articles or K2 items).

Create a menu item of Blog type
Create a menu item of Blog type

The elements you set in the blog that will be part of the feed are:

All elements that are included in the view will be part of the feed UP TO the number of items that is set in the global configuration of the website (in Global Configuration, under the 'Site' tab).

Feeds are limited in length by the setting 'Default feed limit'.

Authors will be included if the 'Feed email address' parameter is set to 'Author email'.

Site global parameters
Site global parameters

In the feed, images are added as content for each item, before the remaining of the text (and before the fields, if any).

<description><![CDATA[<p class="item_image"><img src="https://my_site_of_origin.com/images/alps.jpg" /></p>This is a sample blog posting 3. If you log in to...]]></description>

Step 3 - Site source - Test the feed

To see the feed as a result of your view, go to the view itself and add ?format=feed&type=rss to the URL in the address tab of the browser.

For instance, if your blog view's URL is
https://my_site_of_origin.com/news
then the feed can be seen at
https://my_site_of_origin.com/news?format=feed&type=rss

From that point on, any visitor of your site can get the feed while on the blog, and use it in its own interpreter.

Site target - Showing the feed created in the site source

Solution 1 - Using the News Feeds core extension

Go to Components -> News Feeds. Create a new entry. Set the Link parameter to https://my_site_of_origin.com/news?format=feed&type=rss.

Create a feed entry
Create a feed entry

You can now create a menu item to show that feed.
Go to Menus -> [your menu of choice] -> Add new menu item. Select the menu item type Single News Feed.

Create a menu item of Single news feed type
Create a menu item of Single news feed type

Select the feed entry you have previously created.

Select the feed entry
Select the feed entry

You will end up with a page containing the feed results.

The menu item's output
The menu item's output

Note: in this solution, the feed should contain custom fields (or K2 extra fields) as HTML, not as syntax, unless you created a plugin that can interpret the feed syntax or your created a template override that handles the syntax

Solution 2 - Using the Feed Display module

Go to Extensions -> Modules. Create an instance of the module Feed Display. Set the Feed URL parameter to https://my_site_of_origin.com/news?format=feed&type=rss.

Set the Feed Display module instance
Set the Feed Display module instance

The output should return something like this:

The module's output
The module's output

Note: in this solution, the feed should contain custom fields (or K2 extra fields) as HTML, not as syntax, unless you created a plugin that can interpret the feed syntax or your created a template override that handles the syntax

Solution 3 - Using the Newsfeeds plugin in conjunction with the Latest News Enhanced module

The Newsfeeds plugin adds feeds support to the Latest News Enhanced module (for the commercial version only). It allows the module to show one or multiple feeds with all the options you are familiar with.

Go to Extensions -> Modules. Create an instance of Latest News Enhanced.

Select the 'Newsfeeds' data source in the Item selection tab (it should be available if the Newsfeeds plugin has remained enabled after install).

Select the Newsfeeds data source
Select the Newsfeeds data source

Enter the 'Additional options' section and add the feed's URL (https://my_site_of_origin.com/news?format=feed&type=rss) into the 'Feeds' parameter.

Set all the options as you would with any Latest News Enhanced instance.
Since the image is in the content of the feed, set 'Head' to 'Image from content'. Set 'Link' to 'Item'.

Now, the text needs to be formatted specifically, depending on how the fields are laid out in the feed item.

The fields are included in the feed as HTML (<dl> tag)

In the Layout tab, I would suggest you strip tags from the text (it will remove the image from the content) but keep tags <dl><dt><dd>.

Formatting text: fields included in HTML code
Formatting text: fields included in HTML code

By keeping specific HTML tags and preventing them from being stripped from the text, it will show the fields in a syntactically correct format, just before the text.

The resulting output for fields as HTML
The resulting output for fields as HTML
The fields are included in the feed as syntax

In the Layout tab, strip tags from the text (it will remove the image from the content) and set 'Trigger events' to 'Yes'. By doing so, you will trigger the parsing of the syntax, the caching of the values and the removal of the syntax from the text.

Formatting text: fields included as syntax
Formatting text: fields included as syntax
Showing feed item information

In the 'Information' tab, you can select any information related to the date and the author.

The Newsfeeds plugin also adds parameters of its own:

Newsfeeds: Fields can be used to show all the fields that are available for the feed item, when added to the feed as a syntax.

Selecting Newsfeeds: Fields
Selecting Newsfeeds: Fields

In that case, the fields will show as a list of items at any place detailed information can be shown.

The resulting output for Newsfeeds: Fields
The resulting output for Newsfeeds: Fields

You can override the output by creating a template override of the layout lnep_detail_newsfeeds_fields.php. For more information on overrides, check the section: Layout overrides. When installed, the plugin added its own layouts to components/com_latestnewsenhancedpro/layouts/details.

Solution 3 - Advanced

It is possible to show each field individually and not as a list of fields. In that case, you need to create your own plugin. And there is a tutorial for that: Add your own information types in Latest News Enhanced Pro.

I have added a specific example to the MyDetails plugin, which deals with the fields found in a feed. You can modify it to handle the fields you want to show.

Use the alias from {field alias=[agegroup] name=[Age Group]}21-30{/field} as the unique identifier when looking for a field's values (more information is included in the code of the sample plugin).

Note that you do not have to create a layout for each field. You can use the same layout to present all fields the same way (pass the values as data to the layout and use the same layout name for all fields).

Selecting your own field
Selecting your own field

Once setup, you will be able to show each field like any other information type in Latest News Enhanced.

The resulting output for individual field representation
The resulting output for individual field representation