How to style Joomla 2.5 article's intro text?
Asked Answered
P

2

7

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

Paella answered 1/9, 2012 at 10:31 Comment(1)
Just as hint, if you want to use content plugins in fulltexts to: $ftext = JHTML::_('content.prepare', $this->item->fulltext); echo $ftext;Lustrate
K
1

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)

Kirschner answered 27/5, 2014 at 19:6 Comment(0)
C
3

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.

Clarance answered 1/9, 2012 at 18:5 Comment(2)
Perfect! I really appreciate your answer. I thought that I had to only change the core component. And you showed me the standard way :)Paella
I've updated my question according to your useful answer. Thanks again.Paella
K
1

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)

Kirschner answered 27/5, 2014 at 19:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.