Draft:Template:Article: Difference between revisions

From AbhiprayaVedi
No edit summary
No edit summary
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>
<includeonly>{{DISPLAYTITLE:{{{DisplayTitle|{{{Title|}}}}}}}}<!--
{{DISPLAYTITLE:{{{DisplayTitle|{{{Title|}}}}}}}}
--><div class="article-container" data-language="{{{Language|}}}">


<!-- Main Content Area with Sidebars -->
<!-- Article Header - Clean, No Duplication -->
<div style="display: flex; gap: 20px; margin: 20px 0;">
<div class="article-header">
<div class="author-info"><span class="author-name">{{{Author|}}}</span><span class="date-info">{{#time:d-m-Y|{{{Date|}}}}}</span><span class="category-badge">{{{Category|}}}</span></div>
</div>


<!-- Left Sidebar - Key Points -->
<!-- Introduction - Compact -->
{{#if:{{{KeyPoint1|}}}|
<div class="introduction-section">
<div class="left-sidebar" style="flex: 0 0 200px; background: #fffacd; border: 2px solid #f0e68c; border-radius: 5px; padding: 15px; font-size: 0.9em;">
{{{Introduction|}}}
<div style="font-weight: bold; color: #8b4513; margin-bottom: 10px; font-size: 1.1em;">📌 പ്രധാന പോയിന്റുകൾ</div>
<ul style="margin: 0; padding-left: 20px;">
{{#if:{{{KeyPoint1|}}}|<li>{{{KeyPoint1|}}}</li>}}
{{#if:{{{KeyPoint2|}}}|<li>{{{KeyPoint2|}}}</li>}}
{{#if:{{{KeyPoint3|}}}|<li>{{{KeyPoint3|}}}</li>}}
{{#if:{{{KeyPoint4|}}}|<li>{{{KeyPoint4|}}}</li>}}
</ul>
</div>
</div>
|}}


<!-- Main Content Column -->
<!-- Two Column Layout -->
<div class="main-content-column" style="flex: 1; min-width: 0;">
<div class="content-wrapper">


<!-- Article Metadata - Prominent -->
<!-- Main Content -->
<div class="article-meta" style="font-size: 1.1em; margin-bottom: 25px; padding: 15px; background: #f5f5f5; border-left: 4px solid #0645ad; border-radius: 3px;">
<div class="main-content">
{{#if:{{{OriginalAuthor|}}}|
'''യഥാർത്ഥ രചയിതാവ് (Original Author):''' {{{OriginalAuthor|}}} | '''പരിഭാഷ (Translated by):''' {{{Author|}}} | '''തീയതി (Date):''' {{{Date|}}} | '''വിഭാഗം (Category):''' {{{Category|}}}
|
'''രചയിതാവ് (Author):''' {{{Author|}}} | '''തീയതി (Date):''' {{{Date|}}} | '''വിഭാഗം (Category):''' {{{Category|}}}
}}
</div>


<!-- Thumbnail -->
<!-- Image 1 - Left Aligned -->
{{#if:{{{Thumbnail|}}}|
{{#if:{{{Image1|}}}|
<div style="float: right; margin: 0 0 15px 15px;">
<div class="image-left">
[[File:{{{Thumbnail}}}|thumb|300px|{{{ThumbnailCaption|}}}]]
[[File:{{{Image1}}}|thumb|400px|{{{Image1Caption|}}}]]
</div>
</div>
|}}
|}}


<!-- Introduction Section with Special Styling -->
<!-- Article Text -->
<div class="article-introduction" style="background: linear-gradient(to right, #e3f2fd, #ffffff); padding: 20px; margin: 0 0 25px 0; border-left: 5px solid #2196f3; border-radius: 3px; font-size: 1.15em; line-height: 1.8; color: #1565c0; font-weight: 500;">
<div class="article-text">
{{{Introduction|}}}
</div>
 
<!-- Main Article Content with embedded image in middle -->
<div class="article-content" style="font-size: 1.05em; line-height: 1.8; text-align: justify;">
{{#if:{{{Image1|}}}|
<!-- Split content to insert image in middle -->
{{{Content|}}}
{{{Content|}}}
<div style="margin: 30px 0; text-align: center; clear: both;">
[[File:{{{Image1}}}|thumb|center|650px|{{{Image1Caption|}}}]]
</div>
|
<!-- No image, just content -->
{{{Content|}}}
}}
</div>
</div>


<!-- Additional Images (Image 2 and 3 only) -->
<!-- Additional Images -->
{{#if:{{{Image2|}}}|
{{#if:{{{Image2|}}}|
<div class="article-images" style="margin: 30px 0;">
<div class="content-image">
<div style="margin: 20px 0; text-align: center;">
[[File:{{{Image2}}}|thumb|center|650px|{{{Image2Caption|}}}]]
[[File:{{{Image2}}}|thumb|center|600px|{{{Image2Caption|}}}]]
</div>
</div>
{{#if:{{{Image3|}}}|
|}}
<div style="margin: 20px 0; text-align: center;">
 
[[File:{{{Image3}}}|thumb|center|600px|{{{Image3Caption|}}}]]
<!-- Source Attribution -->
</div>
{{#if:{{{SourceName|}}}|
}}
<div class="source-attribution">
<strong>സ്രോതസ്സ്:</strong> {{{SourceName|}}}
{{#if:{{{OriginalAuthor|}}}| • <strong>യഥാർത്ഥ രചയിതാവ്:</strong> {{{OriginalAuthor|}}}}}
{{#if:{{{SourceURL|}}}| • [{{{SourceURL|}}} യഥാർത്ഥ ലേഖനം]}}
</div>
</div>
|}}
|}}
Line 73: Line 48:
</div>
</div>


<!-- Right Sidebar - Highlights/Quick Facts -->
<!-- Right Sidebar -->
{{#if:{{{Highlight1|}}}|
<div class="right-sidebar">
<div class="right-sidebar" style="flex: 0 0 220px; background: #e8f5e9; border: 2px solid #81c784; border-radius: 5px; padding: 15px; font-size: 0.9em;">
 
<div style="font-weight: bold; color: #2e7d32; margin-bottom: 10px; font-size: 1.1em;">💡 പ്രത്യേക ശ്രദ്ധയ്ക്ക്</div>
<!-- Author Infobox -->
<div style="line-height: 1.6;">
<div class="author-infobox">
{{#if:{{{Highlight1|}}}|
{{#if:{{{Thumbnail|}}}|
<div style="background: white; padding: 10px; margin-bottom: 10px; border-radius: 3px; border-left: 3px solid #4caf50;">
<div class="author-photo">
{{{Highlight1|}}}
[[File:{{{Thumbnail}}}|frameless|280px]]
</div>
</div>
}}
|}}
{{#if:{{{Highlight2|}}}|
<div class="author-name-box">[[{{{Author|}}}|{{{Author|}}}]]</div>
<div style="background: white; padding: 10px; margin-bottom: 10px; border-radius: 3px; border-left: 3px solid #4caf50;">
{{#if:{{{Author_Bio|}}}|
{{{Highlight2|}}}
<div class="author-bio">
{{{Author_Bio|}}}
</div>
</div>
}}
|}}
{{#if:{{{Highlight3|}}}|
<div style="background: white; padding: 10px; border-radius: 3px; border-left: 3px solid #4caf50;">
{{{Highlight3|}}}
</div>
}}
</div>
</div>
<!-- Highlights -->
{{#if:{{{Highlight1|}}}|
<div class="highlight-box">
<div class="highlight-title">💡</div>
<div class="highlight-text">{{{Highlight1|}}}</div>
</div>
</div>
|}}
|}}


{{#if:{{{Highlight2|}}}|
<div class="highlight-box">
<div class="highlight-title">💡</div>
<div class="highlight-text">{{{Highlight2|}}}</div>
</div>
</div>
|}}


<!-- Source Attribution Section - Compact -->
<!-- Key Points as Floating Box -->
{{#if:{{{SourceName|}}}|
{{#if:{{{KeyPoint1|}}}|
<div class="source-attribution" style="background: #fff9e6; border: 1px solid #ffc107; border-radius: 3px; padding: 12px; margin: 25px 0 20px 0; font-size: 0.95em;">
<div class="keypoints-float">
<strong style="color: #856404;">📰 സ്രോതസ്സ് (Source):</strong>  
<div class="keypoints-header">📌</div>
{{{SourceName|}}}{{#if:{{{OriginalDate|}}}| • പ്രസിദ്ധീകരണം (Published): {{{OriginalDate|}}}}}{{#if:{{{SourceURL|}}}| • [{{{SourceURL|}}} യഥാർത്ഥ ലേഖനം (Original Article)]}}{{#if:{{{TranslationType|}}}| • തരം (Type): {{{TranslationType|}}}}}{{#if:{{{PermissionNote|}}}| <em>{{{PermissionNote|}}}</em>}}
<ul class="keypoints-list">
{{#if:{{{KeyPoint1|}}}|<li>{{{KeyPoint1|}}}</li>}}
{{#if:{{{KeyPoint2|}}}|<li>{{{KeyPoint2|}}}</li>}}
{{#if:{{{KeyPoint3|}}}|<li>{{{KeyPoint3|}}}</li>}}
{{#if:{{{KeyPoint4|}}}|<li>{{{KeyPoint4|}}}</li>}}
</ul>
</div>
</div>
|}}
|}}


<!-- Translator/Author Bio Section -->
{{#if:{{{Author_Bio|}}}|
<div class="author-bio" style="background: #f5f5f5; padding: 20px; margin: 30px 0 20px 0; border-top: 3px solid #9e9e9e; border-radius: 3px;">
<div style="font-size: 1.2em; color: #424242; font-weight: bold; margin-bottom: 10px;">
{{#if:{{{OriginalAuthor|}}}|
✍️ പരിഭാഷകനെക്കുറിച്ച് (About the Translator)
|
✍️ രചയിതാവിനെക്കുറിച്ച് (About the Author)
}}
</div>
</div>
<div style="line-height: 1.6;">
 
{{{Author_Bio|}}}
</div>
</div>
</div>
</div>
|}}


<!-- Categories -->
<!-- ================================================================
[[Category:{{{Category|}}}]]
    CATEGORIES
[[Category:Articles]]
   
    NOTE on Malayalam DEFAULTSORT bug:
    MediaWiki's DEFAULTSORT cannot sort Malayalam Unicode text correctly —
    it only reads the first character, so categories show truncated names.
   
    FIX: We use the "sort key" parameter directly on each [[Category:]] link.
    The sort key is the DisplayTitle passed explicitly, which makes the full
    title appear correctly in the category listing.
    ================================================================ -->
 
[[Category:{{{Category|}}}|{{{DisplayTitle|{{{Title|}}}}}}]]
[[Category:Articles|{{{DisplayTitle|{{{Title|}}}}}}]]
{{#if:{{{Language|}}}|[[Category:{{{Language}}} articles|{{{DisplayTitle|{{{Title|}}}}}}]]|}}
 
<!-- English-to-Malayalam parallel categories -->
{{#switch:{{{Category|}}}
|Politics=[[Category:രാഷ്ട്രീയം|{{{DisplayTitle|{{{Title|}}}}}}]]
|Society=[[Category:സമൂഹം|{{{DisplayTitle|{{{Title|}}}}}}]]
|Culture=[[Category:സംസ്കാരം|{{{DisplayTitle|{{{Title|}}}}}}]]
|Science=[[Category:ശാസ്ത്രം|{{{DisplayTitle|{{{Title|}}}}}}]]
|Literature=[[Category:സാഹിത്യം|{{{DisplayTitle|{{{Title|}}}}}}]]
|Cinema=[[Category:സിനിമ|{{{DisplayTitle|{{{Title|}}}}}}]]
|Environment=[[Category:പരിസ്ഥിതി|{{{DisplayTitle|{{{Title|}}}}}}]]
|Economics=[[Category:സമ്പദ്‌വ്യവസ്ഥ|{{{DisplayTitle|{{{Title|}}}}}}]]
|Opinion=[[Category:അഭിപ്രായം|{{{DisplayTitle|{{{Title|}}}}}}]]
}}
 
{{#if:{{{OriginalAuthor|}}}|
{{#if:{{{OriginalAuthor|}}}|
[[Category:Articles by {{{OriginalAuthor|}}}]]
[[Category:Articles by {{{OriginalAuthor|}}}|{{{DisplayTitle|{{{Title|}}}}}}]]
[[Category:Translations]]
[[Category:Translations|{{{DisplayTitle|{{{Title|}}}}}}]]
[[Category:Translated by {{{Author|}}}]]
[[Category:Translated by {{{Author|}}}|{{{DisplayTitle|{{{Title|}}}}}}]]
|
|
[[Category:Articles by {{{Author|}}}]]
[[Category:Articles by {{{Author|}}}|{{{DisplayTitle|{{{Title|}}}}}}]]
}}
}}
</includeonly>
</includeonly>


<noinclude>
<noinclude>
== Article Template Documentation ==
== Ver3: Fix for Category Display Names ==
 
=== The Malayalam DEFAULTSORT Problem ===
 
`{{DEFAULTSORT:}}` does NOT work correctly with Malayalam (or any Unicode script that is non-Latin). MediaWiki's sort key mechanism only reads the first Unicode code point, which is why categories were showing only the first letter/character of the title.
 
=== The Fix ===


This template creates a beautifully formatted article page with:
Instead of using `DEFAULTSORT`, we now pass the sort key '''directly on each category link''' using the pipe syntax:
* Custom display title (supports Malayalam)
* Prominent metadata line showing original author (for translations) or author
* Colored introduction section
* Optional left sidebar for key points
* Optional right sidebar for highlights
* Support for multiple images/charts within content (Image1 appears in middle of content)
* Compact source attribution line for translations
* Translator/Author bio section
* Automatic categorization (original author for translations, translator for translations)


=== Usage ===
<pre>
<pre>
{{Draft:Template:Article
[[Category:Articles|{{{DisplayTitle|{{{Title|}}}}}}]]
|DisplayTitle=പ്രധാനപ്പെട്ട ലേഖനം
|Title=Important-Article
|Author=പരിഭാഷകന്റെ പേര് (for translations) or രചയിതാവിന്റെ പേര് (for originals)
|OriginalAuthor=യഥാർത്ഥ ലേഖകൻ (only for translations)
|Date=2026-01-14
|Category=Politics
|Thumbnail=Example.jpg
|ThumbnailCaption=Main image description
|Introduction=ലേഖനത്തിന്റെ ആമുഖം...
|Content=പ്രധാന ഉള്ളടക്കം...
|Image1=Chart1.png (appears in middle of article)
|Image1Caption=First chart description
|Image2=Photo2.jpg (appears at end)
|Image2Caption=Second photo description
|Author_Bio=പരിഭാഷകനെക്കുറിച്ച് or രചയിതാവിനെക്കുറിച്ച്...
|KeyPoint1=ആദ്യ പോയിന്റ്
|Highlight1=പ്രത്യേക ശ്രദ്ധയ്ക്ക്
|SourceName=The Hindu (for translations)
|OriginalDate=2026-01-10
|SourceURL=https://example.com/original-article
|TranslationType=Translation
|PermissionNote=Published with permission
}}
</pre>
</pre>


=== Key Changes ===
This tells MediaWiki: "place this page in the category, and display it under the sort key equal to the DisplayTitle." Since MediaWiki renders the sort key as the display label in category listings, the full Malayalam title now appears correctly.
* Page title (H1) appears only once at top (from MediaWiki default)
* Blue styled title removed
* Metadata line is larger (1.1em) and more prominent with background
* Original Author shows in metadata line for translations
* Translator name shows as "Translated by" in metadata
* Image1 appears in middle of content
* Source attribution is compact single line
* Author bio changes to "About Translator" for translations
* Categories show original author for translations
* Category display shows DISPLAYTITLE, not page name
 
=== Parameters ===
'''Basic Information:'''
* '''DisplayTitle''' (required): Title as displayed
* '''Title''' (required): Page name
* '''Author''' (required): Translator name (for translations) or Author (for originals)
* '''OriginalAuthor''' (optional): Original author name (only for translations)
* '''Date''' (required): Publication date
* '''Category''' (required): Article category
 
'''Content:'''
* '''Thumbnail''' (optional): Main image
* '''Introduction''' (required): Brief intro
* '''Content''' (required): Main text
* '''Image1''' (optional): Appears mid-article
* '''Image2-3''' (optional): Appear at end


'''Source (translations only):'''
=== How it works ===
* '''SourceName''', '''OriginalDate''', '''SourceURL''', '''TranslationType''', '''PermissionNote'''


'''Sidebars:'''
{| class="wikitable"
* '''KeyPoint1-4''', '''Highlight1-3'''
! Parameter !! Example value
|-
| Page name || <code>Something-In-The-Air</code>
|-
| DisplayTitle || <code>Something in the Air?</code>
|-
| Category shows || '''Something in the Air?'''
|}


'''Bio:'''
For Malayalam:
* '''Author_Bio''' (changes to translator bio if OriginalAuthor is set)
{| class="wikitable"
! Parameter !! Example value
|-
| Page name || <code>Kerala-Climate-Change</code>
|-
| DisplayTitle || <code>കേരളത്തിലെ കാലാവസ്ഥാ വ്യതിയാനം</code>
|-
| Category shows || '''കേരളത്തിലെ കാലാവസ്ഥാ വ്യതിയാനം'''
|}


[[Category:Templates]]
[[Category:Templates]]
</noinclude>
</noinclude>

Latest revision as of 18:56, 10 April 2026


Ver3: Fix for Category Display Names

The Malayalam DEFAULTSORT Problem

`` does NOT work correctly with Malayalam (or any Unicode script that is non-Latin). MediaWiki's sort key mechanism only reads the first Unicode code point, which is why categories were showing only the first letter/character of the title.

The Fix

Instead of using `DEFAULTSORT`, we now pass the sort key directly on each category link using the pipe syntax:

[[Category:Articles|{{{DisplayTitle|{{{Title|}}}}}}]]

This tells MediaWiki: "place this page in the category, and display it under the sort key equal to the DisplayTitle." Since MediaWiki renders the sort key as the display label in category listings, the full Malayalam title now appears correctly.

How it works

Parameter Example value
Page name Something-In-The-Air
DisplayTitle Something in the Air?
Category shows Something in the Air?

For Malayalam:

Parameter Example value
Page name Kerala-Climate-Change
DisplayTitle കേരളത്തിലെ കാലാവസ്ഥാ വ്യതിയാനം
Category shows കേരളത്തിലെ കാലാവസ്ഥാ വ്യതിയാനം