Personalization of articles Topic is solved

General questions relating to Joomla! 5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Post Reply
effettoMapet
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Apr 10, 2024 4:02 pm

Personalization of articles

Post by effettoMapet » Wed Apr 10, 2024 4:25 pm

Hello and thanks for the help.

To import a module into articles I use the classic {loadmoduleid XX} from the back-end and it works correctly.

However, I would really like to be able to understand how to create the same effect as the 'loadmoduleid' inside the 'com_content > tmpl > article > default.php' file.
I would like to be able to create a space directly in this file where I can display a form.

Is this feasible?
If so, what PHP code should I write?

Thank you all.

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

Re: Personalization of articles

Post by gws » Wed Apr 10, 2024 5:00 pm


Mr. Wimpy
Joomla! Explorer
Joomla! Explorer
Posts: 461
Joined: Fri Dec 02, 2005 10:46 am
Location: The Netherlands

Re: Personalization of articles

Post by Mr. Wimpy » Wed Apr 10, 2024 5:10 pm

I can think of some options:
1. Special module position just for articles

Open your template's index.php file and on the Location where you want the module add:

Code: Select all

<?php if($view == "article") : ?>
  <jdoc:include type="modules" name="myspecialposition" style="html5" />
<?php endif; ?>
* If your template does not have the $view yet, add this line in the top php block

Code: Select all

$view = $input->getCmd('view', '');
See the cassiopeia index.php file...

2. Use Modules Anywhere
https://extensions.joomla.org/extension ... -anywhere/
Add a special snippit of code, {module title="Name of My Module"}, in your article override file.

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

Re: Personalization of articles

Post by SharkyKZ » Thu Apr 11, 2024 8:31 am

You can use this to render a module position:

Code: Select all

echo $this->getDocument()->getBuffer('modules', 'some-position');

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1675
Joined: Tue Jun 30, 2020 12:17 pm

Re: Personalization of articles

Post by Pavel-ww » Sat Apr 13, 2024 8:22 am

effettoMapet wrote:
Wed Apr 10, 2024 4:25 pm
I would like to be able to create a space directly in this file where I can display a form.
Hi.

You can add the module position by overridding Article default.php or create a separate layout of the article, for example you_own_article.php based on default.php. Then you will be able to choose this layout in the article settings.

To add position use this code

Code: Select all

<?php echo JHtml::_('content.prepare', '{loadposition YOUR_POSITION_NAME}'); ?>

effettoMapet
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Apr 10, 2024 4:02 pm

Re: Personalization of articles

Post by effettoMapet » Sat Apr 13, 2024 1:33 pm

Pavel-ww wrote:
Sat Apr 13, 2024 8:22 am
effettoMapet wrote:
Wed Apr 10, 2024 4:25 pm
I would like to be able to create a space directly in this file where I can display a form.
Hi.

You can add the module position by overridding Article default.php or create a separate layout of the article, for example you_own_article.php based on default.php. Then you will be able to choose this layout in the article settings.

To add position use this code

Code: Select all

<?php echo JHtml::_('content.prepare', '{loadposition YOUR_POSITION_NAME}'); ?>

Fabulous works great!

And if I wanted to do the same thing but to create a space for the additional fields, can you tell me what code I need to use?
THANK YOU

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1675
Joined: Tue Jun 30, 2020 12:17 pm

Re: Personalization of articles

Post by Pavel-ww » Sun Apr 14, 2024 8:23 am

effettoMapet wrote:
Sat Apr 13, 2024 1:33 pm
And if I wanted to do the same thing but to create a space for the additional fields, can you tell me what code I need to use?
Hi. I'm not sure that I understand you correctly. What do you mean by "additional fields"?

If you mean Article's Custom Fields, you can configure the display place in the field's settings.
You do not have the required permissions to view the files attached to this post.

effettoMapet
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Wed Apr 10, 2024 4:02 pm

Re: Personalization of articles

Post by effettoMapet » Sun Apr 14, 2024 11:14 am

Yes, you understood correctly, but I want to add new custom positions beyond the system default ones (the ones you highlighted)

Thank you !

User avatar
Pavel-ww
Joomla! Ace
Joomla! Ace
Posts: 1675
Joined: Tue Jun 30, 2020 12:17 pm

Re: Personalization of articles

Post by Pavel-ww » Mon Apr 15, 2024 7:57 am

effettoMapet wrote:
Sun Apr 14, 2024 11:14 am
Yes, you understood correctly, but I want to add new custom positions beyond the system default ones (the ones you highlighted)

Thank you !
Hi. There is no simple solution with the fields, as with modules. The default output places cover 99% of the needs. The rest can be adjusted through CSS. Where do you want to get the fields?


Post Reply

Return to “General Questions/New to Joomla! 5.x”