Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Articles: Inserted modules should be referenced by ID, not by title #19360

Closed
smehrbrodt opened this issue Jan 12, 2018 · 15 comments
Closed

Articles: Inserted modules should be referenced by ID, not by title #19360

smehrbrodt opened this issue Jan 12, 2018 · 15 comments

Comments

@smehrbrodt
Copy link
Contributor

smehrbrodt commented Jan 12, 2018

Steps to reproduce the issue

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.

Expected result

Module identified by module type and ID:
{loadmodule mod_example,123}

Actual result

Module indentified by module type and name
{loadmodule mod_example,Module title}

System information (as much as possible)

Joomla 3.8.3

Additional comments

--

@Bakual
Copy link
Contributor

Bakual commented Jan 12, 2018

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.

@smehrbrodt
Copy link
Contributor Author

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.

@mbabker
Copy link
Contributor

mbabker commented Jan 12, 2018

+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).

@brianteeman
Copy link
Contributor

brianteeman commented Jan 12, 2018

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

/** Use the API, if editor supports it **/

and then update the plugin itself to recognise id and not title

@Bakual
Copy link
Contributor

Bakual commented Jan 12, 2018

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.

@alikon
Copy link
Contributor

alikon commented Jan 12, 2018

something like
{loadmodule module, id:12345}
or
{loadmodule id:12345}
sounds like a good idea

@mbabker
Copy link
Contributor

mbabker commented Jan 12, 2018

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".

@alikon
Copy link
Contributor

alikon commented Jan 12, 2018

then some kind of this syntax maybe ?
{loadmoduleid id:12345}

@alikon
Copy link
Contributor

alikon commented Jan 12, 2018

without the JS side #19362

@joomla-cms-bot
Copy link

Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/19360

@Quy
Copy link
Contributor

Quy commented Jan 13, 2018

see PR #19362


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/19360.

@iamrobert
Copy link
Contributor

iamrobert commented Nov 7, 2019

It works in latest Joomla with:

{loadmoduleid 200}

200 specify module id

@hakanara
Copy link

@ReLater
Copy link
Contributor

ReLater commented Feb 27, 2020

@hakanara
Done!

(Anybody can write docs or update them. You, too ;-) Just register on https://docs.joomla.org/ and start.)

@hakanara
Copy link

Thank you very much @ReLater . I didn't know that but I would like to learn :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants