2

I'm writing a Joomla plugin where I want it to look through the Joomla Articles (and modules) for this:

{myplugin} partno=12345678 {/myplugin}

and change {myplugin} partno=12345678 {/myplugin} to a text string which contains HTML.

I suspect this is going to modify

$row->text 

which I believe contains the Joomla Article (and module) contents in the examples I've seen online.

Is there a common Joomla developer's built-in function to do this? Or is there a more commonly accepted way to do this?

I think it would be accept for it to process this format instead of that makes it more of an acceptable way to do this:

{myplugin} 12345678 {/myplugin}

1 Answer 1

2

Not sure of what you would expect by a Joomla developers built-in function. It seems that you are already up-to the task for creating your content plugin. What you want to process and how you will process it, depends on your needs.

What will be the requirement to place inside your {myplugin}...{/plugin} snippet, should make sense to what you want to accomplish.

If "partno" is important then use it, if just placing the numbers part is sufficient then go this way.

8
  • I guess I was expecting something like using a function like JEventDispatcher that would handle extraction of the {myplugin} that I wasn't aware of. Just trying to do what is best practice or at least elegant in a programming style. Nov 22, 2017 at 17:41
  • @Edward_178118 Still not sure what you want / what you have in mind with extraction of the {myplugin}. What is a function like JEventDispatcher - what you mean with that? JEventDispatcher is a Class used in Joomla's plugin implementation system. From your question I understand that you are already developing a content plugin. When you access the $artilce->text, there you will find your custom {myplugin} snippet and process it how you like - it's pure php there and up to you, to do whatever you want to do. Let me know if I still get this wrong.
    – FFrewin
    Nov 22, 2017 at 18:04
  • 1
    @Edward_178118 - yes, absolutely acceptable
    – FFrewin
    Nov 22, 2017 at 18:08
  • 1
    @Edward_178118 this is another question. It depends on your editor and likely you can find similar questions in JSE. One other possible way to add many partno would be to accept multiple comma seperated numbers within the same snippet. There could be other creative ways though. E.g. combine custom fields on articles functionality where user can enter partno number data, or other ideas could involve custom xtd-editor buttons that will inject special preformed content.
    – FFrewin
    Nov 23, 2017 at 7:38
  • 1
    @Edward_178118 overall, i don't think it should pose a big problem if you have paragraphs or breaks between your many snippets
    – FFrewin
    Nov 23, 2017 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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