Insert a module into an article.
The module gets referenced by its type and name.
However, when changing the name of the module (maybe unknowing that the module is used in an article), this doesn't work anymore.
Rather the ID should be used which doesn't change.
Module identified by module type and ID:
{loadmodule mod_example,123}
Module indentified by module type and name
{loadmodule mod_example,Module title}
Joomla 3.8.3
--
Labels |
Added:
?
|
If you reference by ID, you could take off the type as that information isn't needed anymore.
Correct. However, maybe that's helpful information? I don't really care.
And of course the same error could happen with an ID as well if someone accidentally deletes a module. Only that he will have no luck recreating it once he notices the error.
What I do is to put a note on modules I use in articles "This is used in an article". So I wouldn't delete it by accident.
But still I'd like to change the title without going through all articles and update the module title there as well.
+1 for supporting syntax using the module ID. There are tradeoffs in each direction if you're using syntax using module names or IDs, but I'd suggest the ID syntax is less prone to being broken by other site changes short of deleting the module (FWIW in one of my older projects this was feature requested because of how easily the plugin was broken by changing the title on referenced content, and because that plugin supported title references to content which might have duplicate titles so the right reference wouldn't resolve but using ID it always would).
Makes sense to me. Should be a relatively easy change to make the plugin insert the id instead of the module title. Its all JS in here
and then update the plugin itself to recognise id and not title
The JS is only one part. The content plugin currently doesn't support referencing the ID so that needs to be added to it and the syntax needs to be distinguishable from the old loadmodule behavior (may be possible by checking for integer).
Then we need a way to fetch the module by its ID. Currently the ModuleHelper class doesn't allow this. Maybe there is already an API in another class that could be used.
something like
{loadmodule module, id:12345}
or
{loadmodule id:12345}
sounds like a good idea
Definitely should have some sort of id:
prefix otherwise you start introducing magic behaviors trying to handle it differently based on whether an integer or string is given. About the only possible problem that's created is you implicitly block creating modules named "id:XX".
then some kind of this syntax maybe ?
{loadmoduleid id:12345}
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-01-13 17:10:36 |
Closed_By | ⇒ | Quy |
Closed_By | Quy | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/19360
see PR #19362
It works in latest Joomla with:
{loadmoduleid 200}
200 specify module id
@hakanara
Done!
(Anybody can write docs or update them. You, too ;-) Just register on https://docs.joomla.org/ and start.)
If you reference by ID, you could take off the type as that information isn't needed anymore.
I think it is done like this so it is easier to understand what module is inserted in a given article. Using an ID you will have to lookup up the module in the module manager.
And of course the same error could happen with an ID as well if someone accidentally deletes a module. Only that he will have no luck recreating it once he notices the error.