Override components/com_users/models/forms/login.xml - Joomla 2.5?

巧了我就是萌 提交于 2019-11-29 16:37:19
Shaz

Here's a solution:

http://forum.joomla.org/viewtopic.php?t=583380#p2375649

I just tested it in Joomla 2.5.3 and it works.

Update

here is the solution copied from above URL

We can override output by using the normal template override feature. For me, I'm trying to override the login page. So, I'm taking a copy of /components/com_users/views/login/tmpl/default.php and putting it into /templates/beez_20/html/com_users/login.

Now take a copy of /components/com_users/models/forms/login.xml and place in /templates/beez_20/html/com_users/login as well.

Then edit /templates/beez_20/html/com_users/login/default.php and add at the top of the form (I added mine just after the form tag) the following lines of code:

// to reset the form xml loaded by the view
$this->form->reset( true );

// to load in our own version of login.xml
$this->form->loadFile( dirname(__FILE__) . DS . "login.xml");

Similarly you can safely edit /templates/beez_20/html/com_users/registration/registration.xml to modify the registration form.

The answer posted in the forum that @Shaz definitely works, but for Joomla 3.X you have to tweak a little, so it would be

First of all you copy

/components/com_users/models/forms/login.xml

To

/templates/YOUR_TEMPLATE/html/com_users/login/forms/login.xml

And place this piece of code right at the top

if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR);

$this->form->reset( true ); // to reset the form xml loaded by the view
$this->form->loadFile( dirname(__FILE__) . DS . "forms" . DS . "login.xml"); // to load in our own version of login.xml

This did the tick for me a kudos for the user @dylanjh that posted the original answer on the Joomla forum

I was able to leverage Griiettner's solution for Joomla 3. I wanted to not allow users to edit their email address in the profile edit screen on the frontend. I only modified it slightly, copy this file:

components/com_users/models/forms/profile.xml

to:

/templates/YOUR_TEMPLATE/html/com_users/profile/forms/profile.xml

Also copy this file:

components/com_users/views/profile/tmpl/edit.php

to:

/templates/YOUR_TEMPLATE/html/com_users/profile/edit.php

And put this code at the top of the edit.php file right after the:

defined('_JEXEC') or die;

I left out the $this->form->reset( true ); // to reset the form xml loaded by the view and only used this:

// JOOMLA 3 if(!defined('DS')) define('DS', DIRECTORY_SEPARATOR); $this->form->loadFile( dirname(__FILE__) . DS . "forms" . DS . "profile.xml");

This allowed me to keep the user profile information populated in the edit form. I then edited the profile.xml file and added:

readonly="true"

to the email1 and email2 fields. This prevents the user from editing.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!