2

I try to find a way to auto insert code or text to every article on submission. I find this article on joomla https://docs.joomla.org/Add_text_to_an_article_using_template_overrides ,that uses template overrides to make this happen.Using this code:

var text = <?php 
    $addToText = '<p>Joomla! automatically added this text.</p>'; 
    if (strpos($this->article->text, $addToText) == 0) {
           $this->article->text .= $addToText;
    }
   echo $this->editor->getContent( 'text' ); ?>

on form.php file

,but this article is very old, i guess from joomla 1.5...

4
  • Are you trying to display a specific text after every article?
    – saibbyweb
    Oct 11, 2016 at 16:34
  • I want to try to insert <hr id="system-readmore" /> after a specific number of characters inside my articles.
    – Charis
    Oct 18, 2016 at 8:49
  • Have you tried this : docs.joomla.org/…
    – saibbyweb
    Oct 19, 2016 at 12:20
  • This is the manual way to insert readmore in articles. I need the automatic way using template override.
    – Charis
    Oct 20, 2016 at 15:17

1 Answer 1

1

For what you describe, you will need to look into writing a plugin rather than using template overrides. You should be able to grab the content before it saves to the database and add any extra code at that point.

I think onContentBeforeSave would be the appropriate event to use in your case.

Template overrides still work in Joomla 3, but they just render the content differently rather than actually save it. Depending what you want to do, this may also work. A more up-to-date article on that is here: https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.