Reputation: 2298
I know this is a sort of "old" question, searching around I found couple threads on the joomla forum, but many date back to '09/'10 for 1.5 or 1.6, and none of them have found a real practical solution for this.
So how can a subtitle element be inserted in an article, and fetched into an override for a module or component in Joomla? (I'm interested in a solution for 2.5+, if this can help)
An idea that came to my mind is to add the subtitle right in the same field of the article title, after a special character or word, or a combination of the two, for example: My title_sub_My subtitle
.
Then in the override file with PHP, fetch the $title
variable (or whatever it is), parse the text and if that special separator occurs, split the variable in two more variables to be used in the code output, for example something like:
$title = 'My title_sub_My subtitle'
becomes
$mainTitle = 'My title'
$subTitle = 'My subtitle'
Unfortunately I'm really a beginner with PHP, and I have very basic knowledge on how to achieve such a result, or even if it is possible at all, maybe due to the Joomla CMS structure or other complications.
If what I just said is total bullcrap or there's a better way to achieve a subtitle for articles, what should be done? Thank you!
Upvotes: 1
Views: 2997
Reputation: 545
editing the core of joomla may lost your script with update. in the override you can write:
<?php
$itemTitle = $item->title; // 'My title_sub_My subtitle'
list($title, $subtitle) = explode("_sub_", $itemTitle);
echo $title;
echo "<span class='subtitle'>".$subtitle."</span>";
?>
Upvotes: 0
Reputation: 45124
You can do it easily. Read the below link.
How to add additional field in the Joomla article
Upvotes: 3