[del]
Labels |
Added:
?
|
I wouldn't do that in core as there is to much risk of breaking something.
It's simple enough to do it in an override if needed.
The layout has access to both introtext and fulltext as @ReLater already pointed out. You just need to copy the conditionals from the view (depending on parameter if intro should be shown or not) and wrap it into the tags you want. Eg:
<?php if ($item->params->get('show_intro', '1') == '1') : ?>
<span class="introtext"><?php echo $item->introtext; ?></span> <?php echo $item->fulltext; ?>
<?php elseif ($item->fulltext) : ?>
<?php echo $item->fulltext; ?>
<?php else : ?>
<span class="introtext"><?php echo $item->introtext; ?></span>
<?php endif; ?>
But the joy of $item->text is for example that plugins are triggered on it (they usually don't work with introtext and fulltext).
It's actually as complex as pressing a button in the Joomla backend to create the override of the layout.
Editing it is a bit more tricky of course as you need some minimal coding skills - or the ability to copy-paste from a Google result. They also need some skills in CSS and need to know how to add custom CSS rules.
I'd say those users who have such a need, can figure it out.
But then, most of the time it's templates who do that. They already ship with the override and the specific CSS and the user doesn't have to care at all.
To conclude how easy it is:
$item->introtext
Compared to:
.introtext
- CSS-classI definitely prefer the latter case
I definitely prefer the latter case
Obviously, but it doesn't work for core because you would have to make sure you don't break content by inserting some HTML tags into it. Eg if we add a "" around the introtext it would not work because the text could contain a div or p element. If we however add a div around the introtext, it would add linebreaks which may not be expected.
I don't see how this could be done within core.
If you do it yourself in your template as an override or alternative layout, it's up to you to make sure you don't break anything.
Also, content plugins would almost all break since they only take care of "text" and not "introtext" and "fulltext".
I get your B/C concerns, but It would be a great step forward to have the ability to differenciate between "introtext" and "fulltext" and as alternative legacy "text" for intro and fulltext combined.
And yes, it will break content-plugins which rely only on "text", but that is something, which could easily be fixed by replacing "text" with "fulltext" in the plugincode or, when Joomla provide a legacy "text" for both, they would still work, right?
OT... Just my personal opinion on B/C breakage, if I have a major version change, i would expect a big B/C break everywhere and prefer that more than expecting that old code still works.
Joomla's decision to prefer B/C compatibility over a consequent redesign of Code to recent code standards and underlying programming language versions is for a major version change a too conservative thinking.
I get your B/C concerns, but It would be a great step forward to have the ability to differenciate between "introtext" and "fulltext" and as alternative legacy "text" for intro and fulltext combined.
I haven't mentioned B/C at all. That's not my concern.
And yes, it will break content-plugins which rely only on "text", but that is something, which could easily be fixed by replacing "text" with "fulltext" in the plugincode or, when Joomla provide a legacy "text" for both, they would still work, right?
You're aware that content plugins are supposed to run on all content, not only articles? So no, plugins should never run on intro and fulltext. That's why they usually run on text so they also work for other extensions.
Imho this feature request is a good example for something that can be done easily with a layout override. It's not hard to do, but you have to take care your content fits for it. All in all something one could write in under an hour, write a documentation and others can even copy-paste it when they need it.
I honestly don't think that is something for core (given the chances of breaking content and plugins).
To conclude how easy it is
By experience: You forgot some annoying steps in your list for real life scenarios ;-)
You're free too add them ;-)
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-11-08 13:11:20 |
Closed_By | ⇒ | gostn |
Title |
|
The main problem is that
$this->item->text
in this linehttps://github.com/joomla/joomla-cms/blob/4.0-dev/components/com_content/tmpl/article/default.php#L100-L102
can contain different content db fields; depending on the settings that a user has made and/or the rights of a visitor. introtext or not. fulltext or not...
I'm using template overrides for each individual site to separate and echo
$this->item->introtext
and$this->item->fulltext
depending on the individual settings. (= annoying work; e.g. if a setting has been changed).A change in core would be welcome from my point of view but I see no suitable place in core to add CSS classes that a user can override then. Maybe in an overridable JLayout, used by the view? Or an additional backend setting?
https://github.com/joomla/joomla-cms/blob/4.0-dev/components/com_content/src/View/Article/HtmlView.php#L216-L231