1084

Is this a valid way to use Modules::run?

Comments for “Is this a valid way to use Modules::run?”
 

Posted by Dom on Saturday 27th January 2024 at 16:15 GMT

Can one do the following type of thing with Modules::run ?

<td><button class="alt" onclick="<?= Modules::run('vtl_data/getColumnInfo', $table); ?>">View Columns</button></td>
Level One Member

Dom

User Level: Level One Member

Date Joined: 12/01/2024

Posted by Davcon on Wednesday 31st January 2024 at 11:42 GMT

Well, let's look at the logic.

You're written some JavaScript and within the JavaScript, PHP is being invoked.

In this instance, the PHP is loading a module and asking the module to do 'something'.

It's impossible for me to tell what the module in question is doing. Does it output a string, for example? Could it be returning a number? Or, could it be returning some kind of JSON? On the other hand, could it be doing something else altogether. I have no way of knowing.

What I would say is, whilst it's possible that the code is good, it's a very unusual coding style. Personally speaking, I would not recommend that purely on the grounds that it's impossible to figure what it's doing just by looking at the code.
Founding Member

Davcon

User Level: Founding Member

Date Joined: 3/11/2018

×