Upgrading Extensions and Plugins to use "new methodology"

For Joomla! 5.x Coding related discussions, you could also use: http://groups.google.com/group/joomla-dev-general

Moderators: ooffick, 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.
Post Reply
rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Wed Apr 10, 2024 11:08 am

Hi

I have a plug in which shows a kml file using google maps and an extension showing a facebook page.

Of course if I turn the Behaviour - Backward Compatibility off then lots and lots of things go belly up !

Are there any instructions as to what changes have to be made ?
I am unable to find anything at all. I cannot even find where this extension is located ?

All of my code and files etc are here: https://tdocplus.co.uk/0a_Empty400/face-book
and
https://tdocplus.co.uk/0a_Empty400/kml- ... e-map-code

There does not seem to be anything published that after two hours on google and the forum that I can find. Probably looking for the wrong words !

I want a SIMPLE step by step instruction - is that too much to ask ?

Richard

robbiej
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Wed Apr 06, 2016 11:22 am

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by robbiej » Fri Apr 12, 2024 6:41 pm

Some significant new concepts were introduced in Joomla 4 and although these aspects make the code more flexible and easier to maintain, there is a threshold to get over in terms of understanding them and converting your extension code. Unfortunately it's not

I would suggest you have a look at https://docs.joomla.org/J3.x:Developing ... to_Joomla4 where it gives a description of what's involved in converting a component, and there are associated videos. You've probably got modules and plugins instead of a component, but the concepts do apply to those types of extensions as well.

The concepts are described at https://manual.joomla.org/docs/general-concepts/ - probably the ones which will affect you most are Namespacing, Extension & Dispatcher, Dependency Injection and Web Asset Manager.

There is also some information about building plugins in the "new methodology" under https://manual.joomla.org/docs/building ... s/plugins/

The equivalent section for modules should hopefully be available within a couple of months.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Fri Apr 12, 2024 7:44 pm

Hi

Thanks for the links.

"This page is unfinished, please use the Edit this Page link at the bottom of this page to help make it more useful."

Yup I agree

Is it time to dump Joomla in favour of Word Press ?

The Community need to come up and support us

Richard

User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2762
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by ceford » Sat Apr 13, 2024 6:54 am


rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Sat Apr 13, 2024 9:38 am

Hi
Thanks for that link.
Its the 4 to 5 changes that have me stumped.
I wrote my plugin in and extension for J 4 and then found they worked 100 % for J3 !
Richard

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 348
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by MarkRS » Sat Apr 13, 2024 1:44 pm

If you give specific examples it would be easier to help.

You can still write old-style code and it will work in J4, so that's not really a yardstick.
It's a community, the more we all contribute, the better it will be.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Sat Apr 13, 2024 1:59 pm

Hi

Please see here: https://tdocplus.co.uk/0a_Empty400/face-book

Scroll to: Structure of "mod_tdocfbk"

What do I have to change here ? The Update and the Language seem to be ok !

In the "root" directory:
index.html
helper.php
mod_tdocfbk.php
mod_tdocfbk.xml
In the "tmpl" sub-directory
index.html
default.php

And then any mods to the files especially mod_tdocfbk.xml [root]

Richard

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 348
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by MarkRS » Sat Apr 13, 2024 2:36 pm

If you're having a specific problem somewhere, say exactly where, and what.

Call me lazy if you like, bit while I, and many others, am happy to help I do have my own work/life going on, so making it easy to help will probably get you more help.
It's a community, the more we all contribute, the better it will be.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Sat Apr 13, 2024 2:39 pm

Mark RS

And that is exactly the problem !

I need to know what the new "constructs" are.

You can probably use the mark 1 eyeball and say there, there and there .

At 77 I am now bewildered with the undocumented changes.

Richard

MarkRS
Joomla! Explorer
Joomla! Explorer
Posts: 348
Joined: Thu Oct 29, 2009 8:28 am
Location: UK

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by MarkRS » Sat Apr 13, 2024 3:44 pm

The main thing I notice is that you're still using the early J3 directory structure.
Move your "helper.php" into a directory src/helper underneath the root. It would be good to use namespacing, it isolates your code from anything else that happens to have the same name.

Create a "forms" directory under your root and put your xml form file in it.

Do look at Robbie's excellent J3-with-J4-changes documents that he refers to above.
It's a community, the more we all contribute, the better it will be.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Sat Apr 13, 2024 6:07 pm

Hi all

Thanks for the info
viz: Joomla! Programmers Documentation for Joomla 5.0

It seems I have a lot of learning to do to get a small php file to run - all it does is run a small script which displays a facebook page !

R

robbiej
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Wed Apr 06, 2016 11:22 am

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by robbiej » Sun Apr 14, 2024 2:36 pm

Yeah, I sympathise with you about the lack of documentation; I have in mind to write a description of what you have to do to upgrade a module - I just haven't got round to it yet.

However, if you point me to a zip file for your module and work out a way of communicating directly between us then I'll sort out the code changes for you.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Mon Apr 22, 2024 11:15 am

Robbie
There are two and you can download them from the Joomla Extensions Directory - keyword to find then is simply TDOC.
Attached anyway
[email protected]
You do not have the required permissions to view the files attached to this post.

robbiej
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Wed Apr 06, 2016 11:22 am

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by robbiej » Thu Apr 25, 2024 8:52 pm

I've updated the gmap plugin at https://drive.google.com/file/d/13771Pm ... drive_link

I've updated it to use more recent Joomla mechanisms - see https://manual.joomla.org/docs/building ... ent-plugin for a plugin similar to yours.

However, I think it would have been ok at Joomla 5 at least.

You should really check the application context (site / administrator / api) in the plugin (which I've added) and also the context (eg "com_content.article") (which I haven't added), as onContentPrepare gets triggered in different application contexts and by different components (eg com_contact as well).

The updated module is at https://drive.google.com/file/d/1Eelh8z ... drive_link
To avoid compatibility problems I think you just needed to replace JFactory by its namespaced equivalent. These mappings are in the classmap.php file:

In libraries/classmap.php in Joomla 4

In plugins/behaviour/compat/src/classmap/classmap.php in Joomla 5

I've added the module namespacing to the helper file, but you don't really need this as you never call it.

At some point you should move to using the Web Asset Manager for managing your js code. I'm going to update the basic module tutorial and include how to do that - should be available at https://manual.joomla.org/docs/building ... s/modules/ shortly.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Fri Apr 26, 2024 8:52 am

Robbie

Thanks for the mods . . . which I will examine carefully.

I am a "minimalist" when it comes to coding and web sites. My software TDOC started in "dbase", got "clippered" and then "windowed" using CA Visual Objects, and it is still in use today - last build was in 2020 !

I developed the two extensions because I could not find anything on JED to replace what I was using.

It seemed obvious to publish what I had written. Documented in detail on https://tdocplus.co.uk/0a_Empty400/ mainly for my own records ! So I will update that as well.

I am now approaching 77 - and am not contemplating doing things for much longer . . . my original java script site still works well - tdoc.net.

Anyway, thanks a million . . .

Richard

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Sat Apr 27, 2024 2:28 pm

Robbie

Am starting to test the new version of the Facebook Module.

So the new version will only be for J5 . . .

So the mod_tdocfbk_update.xml needs to be updated.

So I guess this line needs to be
<targetplatform name="joomla" version="5.*"/> [was version=".*"]
and while I am at it:
<php_minimum>8.1</php_minimum> [was 7.2]

Richard

robbiej
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Wed Apr 06, 2016 11:22 am

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by robbiej » Thu May 02, 2024 7:13 pm

Hi Richard,

Yes, I think that might be the minimum php for Joomla 5.

I'm working my way through documenting the module tutorial, so it's not yet merged into the joomla manual, but you can find the step that handles supporting javascript at http://pr-261.manual.joomlacode.org/doc ... javascript (make sure that version 4.4 is selected).

The joomla web asset manager makes life so much easier, so it's worth giving it a try.

So I've got nearly 10 years more of coding before I reach your stage!

Robbie

SharkyKZ
Joomla! Hero
Joomla! Hero
Posts: 2966
Joined: Fri Jul 05, 2013 10:35 am
Location: Parts Unknown

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by SharkyKZ » Thu May 02, 2024 7:34 pm

robbiej wrote:
Thu May 02, 2024 7:13 pm
Hi Richard,

Yes, I think that might be the minimum php for Joomla 5.

I'm working my way through documenting the module tutorial, so it's not yet merged into the joomla manual, but you can find the step that handles supporting javascript at http://pr-261.manual.joomlacode.org/doc ... javascript (make sure that version 4.4 is selected).

The joomla web asset manager makes life so much easier, so it's worth giving it a try.

So I've got nearly 10 years more of coding before I reach your stage!

Robbie
That's not really a modern module. Like other extensions, modules should have a service provider.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Fri May 03, 2024 8:10 am

SharkyKZ

You say that: modules should have a service provider.

Both Facebook and Google Maps provide the "service" by way of parsing the scripts etc.

Where can I find out more about this concept, and what should it contain ?

Richard

User avatar
ceford
Joomla! Hero
Joomla! Hero
Posts: 2762
Joined: Mon Feb 24, 2014 10:38 pm
Location: Edinburgh, Scotland
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by ceford » Fri May 03, 2024 10:55 am

In this article: https://www.dionysopoulos.me/book.html - scroll down to the Modules section and you will see a section entitled Service Provider.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Fri May 03, 2024 11:12 am

ceford
Thanks for that . . .
At 77, I am getting near the stage of not wanting to be bothered . . .
Robbiej has done a splendid job tweaking my code - but I simply do not understand it !
Richard

User avatar
carlitorweb
Joomla! Intern
Joomla! Intern
Posts: 68
Joined: Tue May 08, 2018 9:03 pm

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by carlitorweb » Fri May 03, 2024 5:34 pm

rgtr wrote:
Fri May 03, 2024 11:12 am
ceford
Thanks for that . . .
At 77, I am getting near the stage of not wanting to be bothered . . .
Robbiej has done a splendid job tweaking my code - but I simply do not understand it !
Richard
Is good enough to take a look to a module in the Joomla core, to easy figure out how the new structure work. Plus, read some documentation you already got by others here, will exaplin you those part you still not understand. You cant upgrade your code without read how work for next version.
The future will be automated, decentralized, and digital.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Wed May 15, 2024 2:42 pm

Guys

Now that I have read Nicholas K. Dionysopoulos' book I at least have an understanding of what the changes are about, and Robbie J's mods now make sense to me.

The module to display a Facebook page in a Site Module have been made, and tested, and better still released at Version 5.3.1 dated 26th April 2024 and published on JED. For example please see http://parkdavidson.co.uk/ which is working with Compatibility OFF.

However, the plugin to display a KML file in GoogleMaps has not proceeded as smoothly.
The modifications are complete, and testing is under way. The authorisation by GoogleMaps is by way of a script, and within the J5 configuration it fails - but when there is no Google API Key then it works as expected - viz one gets a message to say "For development purposes only".
Please see the attached screen shots.

One can conclude as follows:
a) that the J5 mods made for me by Robbie work
b) that there has been an error since creation of the plugin, but it was not severe.
c) this error must now be treated as severe. One has to view the java

This is the php code for the script:
// script for authorisation and callback to map script
function getmyauth($apikey) {
$output = '<script src="https://maps.googleapis.com/maps/api/js ... "></script>' ;
return $output ;
}

Here is what Google Maps say: https://developers.google.com/maps/docu ... aps-js-api
scroll down to "The URL in the following example script tag loads the Maps JavaScript API:"

Google Maps suggest that all is required is the word async after the <script before the src ..... but that does not seem to work

Previous testing showed that the script needs to be in the body of the html forming the article.

Any ideas ??

I have a feeling the solution will be very simple . . . so off for a walk and pint !

Richard
You do not have the required permissions to view the files attached to this post.

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Thu May 16, 2024 10:13 am

Hi

The solution IS SIMPLE. I have to redo the building of the scripts in php.

THAT is a very time consuming and laborious task. One mini error with a space or a "." and .... disaster.

Anyone bright eyed and bushy tailed want to do it ?? AND take ownership of the plugin ?

Richard

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Fri May 17, 2024 3:15 pm

Zannatulrupa

The upgrading has been done and is successful.

However, GoogleMaps has a new API - i.e. the two scripts have been revised . . . and that is very hard work at my age.

Richard

gws
Joomla! Champion
Joomla! Champion
Posts: 6046
Joined: Tue Aug 23, 2005 1:56 pm
Location: South coast, UK
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by gws » Fri May 17, 2024 3:28 pm

@rgtr Zannatulrupa is a Troll / spammer. Ignore it.

robbiej
Joomla! Apprentice
Joomla! Apprentice
Posts: 48
Joined: Wed Apr 06, 2016 11:22 am

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by robbiej » Sat May 18, 2024 9:43 pm

I think you'll find it easiest to use the web asset manager, as described in http://pr-261.manual.joomlacode.org/doc ... javascript and in https://manual.joomla.org/docs/general- ... definition - you just add async as an attribute in the joomla.asset.json file (in the same way that 'defer' is added in that second link).

If you're stuck then I'm happy to have a look at it as well if you like, just point me to the code. I've done another site which involved drawing routes using javascript and the Google maps API v3. I found it a bit fiddly with the async, but got it to work in the end. The web asset manager should make it a lot easier.

I might even try the White Cart Walkway when we're over in Barrhead next week!

Robbie

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Sun May 19, 2024 8:33 am

Robbie
I am half way there . . .
But if I get stuck ....
Richard

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Sun May 19, 2024 11:08 am

Robbie

how do I send you my files ?

um m m m getting a daft message when visiting system/extensions and system/plugin

An error has occurred.
0 syntax error, unexpected token "for" no news as to where and what !

richard
my email [email protected]

rgtr
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 218
Joined: Tue Sep 01, 2009 11:31 am
Location: Glasgow
Contact:

Re: Upgrading Extensions and Plugins to use "new methodology"

Post by rgtr » Sun May 19, 2024 12:10 pm

Robbie

I have uploaded all to my google docs drive

https://drive.google.com/drive/folders/ ... sp=sharing

in tdocgmap.php, the assembly of the scripts starts at line 158

Richard


Post Reply

Return to “Joomla! 5.x Coding”