Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to style Joomla 2.5 article's intro text?

It's very strange but I haven't found a really good solution by googling joomla style intro text.

I want that the current output:

<div class="item-content">
    <p>Intro Text</p>
    <p>Full Text</p>
</div>

to be replaced by:

<div class="item-content">
    <div class="introtext"><p>Intro Text</p></div>
    <div class="fulltext"><p>Full Text</p></div>
</div>

I was sure that Joomla itself should have declared such a class for introtext or at least should have a configurable option for that.

What I do NOT want:

  • A Joomla 1.x or Joomla 1.5 solution
  • A manual way until there is not an extension-base solution (which is more more strange!)

UPDATE after {THIS} answer

Now I have a problem with $this->item->introtext, $this->item->fulltext and $this->item->text.

I expect $this->item->introtext to show ONLY introtext, but it also contains the contents AFTER READ MORE.

What property should I use to only include contents BEFORE READ MORE, not anything else?

I don't expect that the $this->item->introtext content be affected by Show Intro Text parameter in article options. It is expected that only $this->item->text cares about it. Am I right?

Note: $this->item->fulltext works as expected and outputs only the contents AFTER the READ MORE.


In case of disabling Show Intro Text parameter in article options, all of the 3 variables, return the text after READ MORE. This should really be considered as a bug.

It would be more wisely to have a variable to return only intro text (in any situation), a variable to return only full text (in any situation), and a variable to include/exclude introtext according to the article parameter: Show Intro Text

like image 308
Mohammad Naji Avatar asked Sep 01 '12 10:09

Mohammad Naji


2 Answers

All you need to do is add a template override. You need to make a copy of this file:

/JOOMLA INSTALL/components/com_content/views/article/tmpl/default.php

Make any changes to the code that you want, then upload it here:

/JOOMLA INSTALL/templates/flexibility/html/com_content/article/default.php

Simple as that.

like image 113
Brent Friar Avatar answered Nov 11 '22 01:11

Brent Friar


In Joomla 3.3.0 it just works as you expected:

<div id="introtext"><?php echo$this->item->introtext; ?></div>
<div id="fulltext"><?php echo $this->item->fulltext; ?></div>

(in templates/your_template_name/html/com_content/article/default.php)

like image 29
user3381264 Avatar answered Nov 11 '22 01:11

user3381264