Advertisement

In Article view, separate Introtext and Fulltext

This forum is for general questions about extensions for Joomla! 3.x.

Moderators: pe7er, General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Locked
Sukinoz
Joomla! Intern
Joomla! Intern
Posts: 96
Joined: Sat Aug 01, 2009 5:12 pm

In Article view, separate Introtext and Fulltext

Post by Sukinoz » Thu Apr 05, 2018 1:20 pm

Hello,

We need to separate in the Article view, the Introtext and the Fulltext.

We have made an override of default.php and change this:

Code: Select all

		<?php echo $this->item->text; ?>
For this:

Code: Select all

	The Introtext:
		<?php echo $this->item->introtext; ?>
		The Fulltext:
		<?php echo $this->item->fulltext; ?>
Is it correct? I mean if "item->text" = "item->introtext" + "item->fulltext" ?

Or should we add something more?

Thanks in advanced.
Last edited by imanickam on Sat Apr 07, 2018 2:59 am, edited 1 time in total.
Reason: Moved the topic from the forum Templates for Joomla! 3.x to the forum Extensions for Joomla! 3.x

Advertisement
deleted user

Re: In Article view, separate Introtext and Fulltext

Post by deleted user » Thu Apr 05, 2018 2:44 pm

It'll work, but won't be optimal. Most plugins are only processing the combined text item, not the individual introtext and fulltext items.

User avatar
imanickam
Joomla! Master
Joomla! Master
Posts: 28344
Joined: Wed Aug 13, 2008 2:57 am
Location: Chennai, India

Re: In Article view, separate Introtext and Fulltext

Post by imanickam » Thu Apr 05, 2018 3:00 pm

I have tested this in Protostar and it does work.

What problem do you have? Explaining the problem would help others in helping to resolve your issue.

What template you using?
Ilagnayeru (MIG) Manickam | இளஞாயிறு மாணிக்கம்
Joomla! - Global Moderators Team | Joomla! Core - Tamil (தமிழ்) Translation Team Coordinator
Former Joomla! Translations Coordination Team Lead
Eegan - Support the poor and underprivileged

Sukinoz
Joomla! Intern
Joomla! Intern
Posts: 96
Joined: Sat Aug 01, 2009 5:12 pm

Re: In Article view, separate Introtext and Fulltext

Post by Sukinoz » Thu Apr 05, 2018 9:15 pm

mbabker wrote:It'll work, but won't be optimal. Most plugins are only processing the combined text item, not the individual introtext and fulltext items.
Thanks very much. I understand. This is exactly the answer I were looking for.

Sukinoz
Joomla! Intern
Joomla! Intern
Posts: 96
Joined: Sat Aug 01, 2009 5:12 pm

Re: In Article view, separate Introtext and Fulltext

Post by Sukinoz » Thu Apr 05, 2018 9:17 pm

So, is there another way to insert some code or text between every "introtext" and "fulltext" before it combines to "text"?

deleted user

Re: In Article view, separate Introtext and Fulltext

Post by deleted user » Thu Apr 05, 2018 10:57 pm

The cleanest thing I can think of would be to create a system plugin (this part is important because it will affect the ordering of triggered plugins), add a handler for the `onContentPrepare` event, ensure it is the first plugin to be run, and do what you need to do there before the other plugins have the opportunity to run. Trying to do what you are wanting to do in a layout file is too late; the HR element used to tell the editor where to split introtext and fulltext is removed and plugins which parse the text to change things will have already run, so I would suggest you can't reliably inject something at that spot in layouts.

User avatar
effrit
Joomla! Guru
Joomla! Guru
Posts: 846
Joined: Sun Nov 12, 2017 2:21 pm
Location: middle of Russia
Contact:

Re: In Article view, separate Introtext and Fulltext

Post by effrit » Fri Apr 06, 2018 2:16 am

Code: Select all

<?php 
echo JHtml::_('content.prepare', $this->item->introtext);
echo "Oh, My Cod Here!";
echo JHtml::_('content.prepare', $this->item->fulltext);
?>

Sukinoz
Joomla! Intern
Joomla! Intern
Posts: 96
Joined: Sat Aug 01, 2009 5:12 pm

Re: In Article view, separate Introtext and Fulltext

Post by Sukinoz » Fri Apr 06, 2018 10:26 am

mbabker wrote:The cleanest thing I can think of would be to create a system plugin (this part is important because it will affect the ordering of triggered plugins), add a handler for the `onContentPrepare` event, ensure it is the first plugin to be run, and do what you need to do there before the other plugins have the opportunity to run. Trying to do what you are wanting to do in a layout file is too late; the HR element used to tell the editor where to split introtext and fulltext is removed and plugins which parse the text to change things will have already run, so I would suggest you can't reliably inject something at that spot in layouts.
Perfectly explained :eek: Thank you very much. :D

have look for it in Google and read https://docs.joomla.org/J3.x:Creating_a ... entPrepare but it is too much for my php/joomla/progammer knowledge. :(


Just a personal thought: as a user of Joomla, it is strange for me to see that in the article view we can not have control over introtext and fulltext separately. (The only option we have is to hide or to show the introtext, isnt it?)

I can imagine a lot of utilities in this way:
  • - Just for insert something basic like a text "This is the introtext:" and "This is the Full text:"
    - or for display with different css the introtext and the fulltext.
    - or for insert an advertisement.
    - or for insert some Joomla Custom Fields.
    - or in my case, to show a "contact form button"...
If at least Joomla could insert comment tags when it combines introtext and fulltext:

Code: Select all

<!-- Begin Introtext -->
xxx
<!--  End introtext -->
<!--  Begin fulltext -->
yyy
<!--  End fulltext -->
or

Code: Select all

<!--  Before introtext -->
xxx
<!--  After introtext -->
<!--  Before fulltext -->
yyy
<!--  After fulltext -->
This way, we could search and replace these codes with Regularlabs Rereplacer or similar.

(Yes, i know I could insert that code manually inside each article, but i am talking about a web with hundreds of articles, creating 10-15 articles per day by authors and editors)

* * * * * * * * * *

@mbabker , Do you think this is a good idea and we could "propose it" this modification for future joomla releases?

Or maybe it is better/easier/faster to create, as you told me, a new Joomla Plugin which can insert any code (set it previosly in the Plugin´s options) before/after introtext and/or before/after fulltext. ?

deleted user

Re: In Article view, separate Introtext and Fulltext

Post by deleted user » Fri Apr 06, 2018 1:38 pm

The core data model and user design isn't intended to treat introtext and fulltext as separate entities. It's done in the database to make it a bit more efficient to get the part of the article's text to show on list views (category, featured, archived) and to support a "teaser" type feature (where what's stored in introtext isn't rendered on the article view), but beyond that the workflow in com_content treats it as one piece of text content. If you trace through the code, the HR element you see in the editor's HTML view (or the red break line in TinyMCE) isn't even stored in the database, that string is parsed out when splitting the data to save in the database and inserted when combining it when loading from the database in edit context.

https://github.com/joomla/joomla-cms/bl ... #L166-L181 puts it all together based on the user params, and the vast majority of plugins inherently only do their magic on the processed text property as a result.

If your content has nothing that would be manipulated by content plugins (i.e. the loadmodule stuff, or email cloaking), you can render in your layouts the unprocessed introtext and fulltext properties. But if you're using plugins to enhance your content, this is unreliable.

Sukinoz
Joomla! Intern
Joomla! Intern
Posts: 96
Joined: Sat Aug 01, 2009 5:12 pm

Re: In Article view, separate Introtext and Fulltext

Post by Sukinoz » Fri Apr 06, 2018 2:17 pm

mbabker wrote:The core data model and user design isn't intended to treat introtext and fulltext as separate entities. It's done in the database to make it a bit more efficient to get the part of the article's text to show on list views (category, featured, archived) and to support a "teaser" type feature (where what's stored in introtext isn't rendered on the article view), but beyond that the workflow in com_content treats it as one piece of text content. If you trace through the code, the HR element you see in the editor's HTML view (or the red break line in TinyMCE) isn't even stored in the database, that string is parsed out when splitting the data to save in the database and inserted when combining it when loading from the database in edit context.

https://github.com/joomla/joomla-cms/bl ... #L166-L181 puts it all together based on the user params, and the vast majority of plugins inherently only do their magic on the processed text property as a result.

If your content has nothing that would be manipulated by content plugins (i.e. the loadmodule stuff, or email cloaking), you can render in your layouts the unprocessed introtext and fulltext properties. But if you're using plugins to enhance your content, this is unreliable.

Thanks for your patient and thanks for explain it so clear for me (not programmer).

So, the conclusion is "make a plugin".

So, i will work in that way. This is the code that a great person has written for this:

Code: Select all

public function onContentPrepare($context, &$row, $params, $page = 0)
	{
		$allowed_contexts = array('com_content.category', 'com_content.article', 'com_content.featured');

		if (!in_array($context, $allowed_contexts))
		{
			return true;
		}

		$row->introtext .= '<!--  After Introtext -->';
		$row->fulltext .= '<!--  After Fulltext -->';
		$row->text = $row->introtext . $row->fulltext;

		return true;
}
What do you think about it?

PS: maybe this should be changed to "Extensions" subforum.

deleted user

Re: In Article view, separate Introtext and Fulltext

Post by deleted user » Fri Apr 06, 2018 4:39 pm

That would definitely do the trick for what you need.

Advertisement

Locked

Return to “Extensions for Joomla! 3.x”