Create module with variable (id database from my own component)

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

Moderators: ooffick, General Support Moderators

Forum rules
Locked
Ciubas
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Jan 06, 2023 1:53 pm

Create module with variable (id database from my own component)

Post by Ciubas » Fri Jan 06, 2023 1:56 pm

I am creating a simple module by creator but I want to expand it (https://extensions.joomla.org/extension ... e-creator/) so as to somehow pass a variable to it (the position from the database will be read). So in the article, for example, I enter {module:1234 idp=2} (this is correct?) and now how to read this number 2 (load into the module), did I write it correctly?

Question:

1. How put module with variable to article: {loadmoduleid 199,15} this is correct?
2. How read this variable inside module?
Last edited by toivo on Fri Jan 06, 2023 9:55 pm, edited 1 time in total.
Reason: mod note: changed URL to point to JED - please observe the forum rules!

User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 17445
Joined: Thu Feb 15, 2007 5:48 am
Location: Sydney, Australia

Re: Create module with variable (id database from my own component)

Post by toivo » Sat Jan 07, 2023 5:19 am

Welcome to the Joomla forum!

The following suggestion from StackExchange is still valid, recommending a custom plugin, based on plugins/system/loadmodule:
Loadmodule with parameters.

The second reply recommends the Pro version of Modules Anywhere by Regular Labs.
Toivo Talikka, Global Moderator

Ciubas
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Fri Jan 06, 2023 1:53 pm

Re: Create module with variable (id database from my own component)

Post by Ciubas » Sat Jan 07, 2023 11:59 am

I think i need plugin and regex, but don't know how to create this.

Created empty plugin for content
Add to article {promolink 15}
Add to plugin php file echo 'test' and show on article (all)

Now I need write php to create and write simple:

1.
$regex = '/{promocjalink\s(.*?)}/i';

2.
Read the $idp (don't know how yet)

3.
Read this and prepare from database data with html (know how)

4.
Replece in arcitle {promolink 15} the (don't know how)

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 24986
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands
Contact:

Re: Create module with variable (id database from my own component)

Post by pe7er » Sat Jan 07, 2023 4:19 pm

Ciubas wrote:
Sat Jan 07, 2023 11:59 am
I think i need plugin and regex, but don't know how to create this.

Created empty plugin for content
Add to article {promolink 15}
Add to plugin php file echo 'test' and show on article (all)
You can use Joomla's core plugin "email cloaking" as an example.
It's a content plugin that looks for an email address and replaces it with some JavaScript:
https://github.com/joomla/joomla-cms/tr ... emailcloak
Kind Regards,
Peter Martin, Global Moderator
Company website: https://db8.nl/en/ - Joomla specialist, Nijmegen, Netherlands
The best website: https://the-best-website.com


Locked

Return to “Joomla! 3.x Coding”