a-blog cms and RSS feeds

a-blog cms, a Japanese CMS, supports RSS feed output by default.

The feeds are displayed when accessed by adding "rss2.xml" to each directory URL.

I will show you how to change this to a format suitable for multilingual sites.

Building a Multilingual Site with a-blog cms

a-blog cms allows you to build a multilingual site in several ways.

Here is a summary of the multilingual support for RSS fields when building a multilingual site using custom fields and the alias function.

Aliasing is a feature that makes it possible to refer to the same blog at different URLs.

For more details, please refer to the official documentation here.

alias feature | a-blog cms developer

When building an actual multilingual site, it is often necessary to use the "rule function," a feature that allows you to change CMS settings under specific conditions.
If you are interested in the further info. please see the article below.

Create a multilingual site using the Alias feature | a-blog cms developer

Make the RSS template file for multilingual supported

Prerequisite

We assume that you have already created custom fields for English as follows.

  • The English name of your site has been created in a custom field on your blog. Or use an alias name.
  • The English name of the category has been created in the category custom field.
  • The English name of the entry has been created in the entry's custom field.
  • The English name of the user has been created in the User custom field.

Also, use the alias function for displaying English sites.

The alias ID is assumed to be 1.

This alias ID is used in the IF statement condition.

Step01 : Create template files for customization

First, copy the following files directly under the theme file directly you are using.

/themes/system/rss2.xml.

Be sure to copy the above file directly under the theme file, because if you edit the file directly, the edited contents may be lost when the CMS is updated.

The code before customization is as follows.

The module Feed_Rss2 is used in this file.

This module itself is simple and easy to understand, but it is not enough to get custom fields for entries, etc.

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:lang="ja"><!-- BEGIN_MODULE Feed_Rss2 -->
    <channel>
        <title>%{BLOG_NAME}<!-- BEGIN_MODULE Touch_Category --> - %{CATEGORY_NAME}<!-- END_MODULE Touch_Category --></title>
        <link>%{BASE_URL}</link>
        <atom:link href="%{INHERLINK}" rel="self" type="application/rss+xml" />
        <description>%{META_DESCRIPTION}</description>
        <language>ja</language>
        <copyright>Copyright (C) %{Y} %{BLOG_NAME} All rights reserved.</copyright>
        <lastBuildDate>{lastBuildDate}</lastBuildDate>
        <generator>a-blog cms</generator>
        <docs>http://blogs.law.harvard.edu/tech/rss</docs><!-- BEGIN item:loop -->
        <item>
            <dc:creator>{creator}</dc:creator>
            <title>{title}</title>
            <link>{link}</link>
            <description><![CDATA[
                @include("/include/unit-rss.html")
            ]]></description><!-- BEGIN category:veil -->
            <category>{category}</category><!-- END category:veil -->
            <guid isPermaLink="true">{permalink}</guid>
            <pubDate>{pubDate}</pubDate>
        </item><!-- END item:loop -->
    </channel><!-- END_MODULE Feed_Rss2 -->
</rss>

Step02 : Create a module ID for Entry_Body and make custom fields available.

Create a new module ID for Entry_Body with the name Entry_Body_for_RSS, because we will use the module of Entry_Body in addition to Feed_Rss2.


In the Feed_Rss2 module, custom fields are not used, so you do not need to create a module ID.

After creation, check the Fields section of the module ID's Display Settings so that basic settings and custom fields can be displayed.


Step03 : Customize rss2.xml

Modify rss2.xml that you copied directly under the theme file as follows.

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:lang="<!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->en<!-- ELSE -->ja<!-- END_IF -->"><!-- BEGIN_MODULE Entry_Body id="Entry_Body_for_RSS" -->
<channel>
    <title><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->%{ALIAS_NAME}<!-- ELSE -->%{ROOT_BLOG_NAME}<!-- END_IF --><!-- BEGIN_MODULE Touch_Category --><!-- BEGIN_MODULE Category_Field --> - <!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{category_meta_title-en}<!-- ELSE -->{category_meta_title}<!-- END_IF --><!-- END_MODULE Category_Field --><!-- END_MODULE Touch_Category --></title>
    <link>%{BASE_URL}</link>
    <atom:link href="%{INHERLINK}" rel="self" type="application/rss+xml" />
<description><!-- BEGIN_MODULE Blog_Field --><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{blog_meta_description-en}<!-- ELSE -->{blog_meta_description}<!-- END_IF --><!-- END_MODULE Blog_Field --></description>
    <language><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->en<!-- ELSE -->ja<!-- END_IF --></language>
    <copyright>Copyright (C) %{Y} <!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->%{ALIAS_NAME}<!-- ELSE -->%{ROOT_BLOG_NAME}<!-- END_IF --> All rights reserved.</copyright>
    <!-- BEGIN_MODULE Feed_Rss2 --><lastBuildDate>{lastBuildDate}</lastBuildDate><!-- END_MODULE Feed_Rss2 -->
    <generator>a-blog cms</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs><!-- BEGIN entry:loop -->
    <item>
        <dc:creator><!-- BEGIN userField --><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{name-en}<!-- ELSE -->{fieldUserName}<!-- END_IF --><!-- END userField --></dc:creator>
        <title><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{title_en}<!-- ELSE -->{title}<!-- END_IF --></title>
        <link>{titleUrl}</link>
        <description><![CDATA[
            @include("/include/unit.html")
        ]]></description>
        <!-- BEGIN category:veil --><!-- BEGIN categoryField --><category><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{category_meta_title-en}<!-- ELSE -->{category_meta_title}<!-- END_IF --></category><!-- END categoryField --><!-- END category:veil -->
        <guid isPermaLink="true">{titleUrl}</guid>
        <pubDate>{sdate#r}</pubDate>
    </item><!-- END entry:loop -->
</channel><!-- END_MODULE Entry_Body -->
</rss>

As an overview, this customization uses the following modules

  • Entry_Body : Retrieve entry information and associated custom fields
  • Blog_Field : Get the blog information
  • Category_Field : Get the category page you are on
  • Feed_Rss2 : Get the date of the lastBuildDate tag, which is the date of the last delivery

Of the variables in the code, those with the -en suffix are custom fields for English.

However, only the entry title is named title_en with underscore instead of hyphen.

In fact, it would be simple and good if only Entry_Body or Feed_Rss2 could be used to support multiple languages, but it seems difficult.

Now, let's look at the main customization parts.

rss tags

<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0" xml:lang="<!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->en<!-- ELSE -->ja<!-- END_IF -->">

Aliases are used to change the display.

channel tag > title tag

<title><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->%{ALIAS_NAME}<!-- ELSE -->%{ROOT_BLOG_NAME}<!-- END_IF --><!-- BEGIN_MODULE Touch_Category --><!-- BEGIN_MODULE Category_Field --> - <!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{category_meta_title-en}<!-- ELSE -->{category_meta_title}<!-- END_IF --><!-- END_MODULE Category_Field --><!-- END_MODULE Touch_Category --></title>

We use aliases to change the display.

We also use the touch module to display categories on category pages.

This is done using the category field module.

channel tag > description tag

<description><!-- BEGIN_MODULE Blog_Field --><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{blog_meta_description-en}<!-- ELSE -->{blog_meta_description}<!-- END_IF --><!-- END_MODULE Blog_Field --></description>

Switch the display with an alias and use a custom field in the blog for the display content.

channel tag > language tag

<language><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->en<!-- ELSE -->ja<!-- END_IF --></language>

Alias switches the display, and the display content is hard-coded.

channel tag > copyright tag

<copyright>Copyright (C) %{Y} <!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->%{ALIAS_NAME}<!-- ELSE -->%{ROOT_BLOG_NAME}<!-- END_IF --> All rights reserved.</copyright>

The display is switched by alias, and the display content uses the alias name and the global variables of the root blog.

channel tag > lastBuildDate tag

<!-- BEGIN_MODULE Feed_Rss2 --><lastBuildDate>{lastBuildDate}</lastBuildDate><!-- END_MODULE Feed_Rss2 -->

It would be nice if the lastBuildDate tag could only get the date of the latest entry post, but since that seems difficult, we use the Feed_Rss2 module only here and use the lastBuildDate variable to show the last update date.

channel tag > item tag > dc:creator tag

<dc:creator><!-- BEGIN userField --><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{name-en}<!-- ELSE -->{fieldUserName}<!-- END_IF --><!-- END userField --></dc:creator>

The display is switched by alias, and the display content is switched by the user who wrote the entry (Japanese name) or a custom field in that user field (English name).

channel tag > item tag > title tag

<title><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{title_en}<!-- ELSE -->{title}<!-- END_IF --></title>

Aliases toggle the display and custom fields in the entry.

channel tag > item tag > category tag

<!-- BEGIN category:veil --><!-- BEGIN categoryField --><category><!-- BEGIN_IF [%{ALIAS_ID}/eq/1] -->{category_meta_title-en}<!-- ELSE -->{category_meta_title}<!-- END_IF --></category><!-- END categoryField --><!-- END category:veil -->

The display is switched by aliasing, getting the category information of the entry and switching between English and Japanese.


Author Info
Profile Icon

Director of web and marketing

Kota Shimizu

I've been working in web, video, and magazine production fields, experienced planning, design, photography, coding, marketing, and business improvement. I'm an omnivorous director who can handle anything in a widely.