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

I've been trying to override the file login.xml but no matter what I try, the edited version in my template folder doesn't show up.
How can I override this file?
Update
I have tried template/<templatename>/html/com_users/models/login.xml and other variations like template/<templatename>/html/com_users/models/forms/login.xml or template/<templatename>/html/com_users/forms/login.xml etc without any success.

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.

Related

Edit JomSocial Joomla Registration Page & Adding Content

I'm running JomSocial 3.2 on Joomla 3.
I want to add some content to the right side of the registration page.
Some pictures and other contents.
So far, i've been able to get to the "register.index.php" file,
which is the file that displays some of the content in the homepag.
The file is in: "/site_root/components/com_community/templates/default/" folder
but i've not been able to fully edit the whole registration page.
This could be done in many different ways - even without editing any file. Install this extension: http://extensions.joomla.org/extension/advanced-module-manager and when editing module you'll have additional tab called "tasks" There will be field URL, type inside URLs of your registration form. Thanks to this you'll be able to assign modules to registration form.
You could also override for:
ROOT/components/com_community/templates/default/register.index.php
Copy it to:
ROOT/templates/your-template/html/com_community (if you don't have "html" or "com_community" folders, feel free to create them)
Then you may create module position inside file using this code:
$modules = JModuleHelper::getModules( 'reg-positon' );
foreach ($modules as $module) {
$_options = array( 'style' => 'xhtml' );
echo JModuleHelper::renderModule( $module, $_options );
}
Above code creates module position: "reg-positon'. You'll need to type this name manually as it will be not listed on module positions list.
Now you'll need a bit of html to display it on right or left of registration form.

How to use breadcrumbs in Joomla in custom components?

I wrote simple component by this example, but when i entering it i see Home instead of my components name.
And also is it possible to get deeper, for example joomla->my_component->some_other_component, but exactly after mine.
P.S.
Found http://docs.joomla.org/How_to_add_breadcrumbs, but how use it automatically in every view?
Try this:
$mainframe = &JFactory::getApplication();
$pathway =& $mainframe->getPathway();
$breadcrumb = $pathway->setPathway(array());
$pathway->addItem( JText::_( 'YOUR_BREDCRUMB_ITEM' ),'');
Replace YOUR_BREDCRUMB_ITEM with your item name. Hope this will help.

How can I load a template of a view within another view in a component?

I am trying to add a view that I made (a table) to another view that I need to appear again. How can I do this? Actually I am trying to add a view within another view using theloadtemplate function.
This is what I type inside the view, but it does't seem to work, can anyone help?
The message I get is the following
Layout default_reports not found
<div>
<?php $jinput = JFactory::getApplication()->input;
$jinput->set('view', 'reports');
echo $this->loadTemplate("reports");
$jinput->set('view', 'master');?>
</div>
But the view is there...
Using the loadTemplate function, we call only the layout inside the view.
We concatenate two or more layout using the loadtemplate inside the following view.
By default joomla, it call the layout by a prefix as default_. So we have to create a layout as reports means filename as default_reports.php but we need to call the layout as you have mentioned
echo $this->loadTemplate("reports");
If you want to be able to load "layouts" from another "view" in the current view.html.php file, then you can do so as below.
$this->addTemplatePath(JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'anotherview' . DIRECTORY_SEPARATOR . 'tmpl');
$this->setLayout('layoutfromanotherview');

Place certain article anywhere in joomla template

Is it possible in Joomla to place a certain article in a template, additionally to the normal content? I want the article to show up on every page.
You can simply take it from the databse and print its content. In the template, where you want to show the article, write this:
$id=/*Id of the article to show*/;
$db=&JFactory::getDBO();
$db->setQuery("SELECT * FROM #__content WHERE id=$id");
$item=$db->loadObject();
echo $item->introtext;
UPDATE: ENABLE PLUGINS
I can't find where i've used that code and i can't copy-paste it, so i try to write it again by looking at the view.html.php of the com_content:
JPluginHelper::importPlugin('content');
$dispatcher =& JDispatcher::getInstance();
$params = &$mainframe->getParams();
$dispatcher->trigger('onPrepareContent', array (&$item, &$params, 0));
//The last line triggers the onPrepareContent event, so if it does not work maybe you need other events, so try with onAfterDisplayTitle, onBeforeDisplayContent or onAfterDisplayContent
Have you seen this? http://extensions.joomla.org/extensions/news-display/content-embed/7528
It allows you to place any article as a module on your Joomla site. And with modules you can have them displayed site wide.

Joomla own component settings insert article in popup

I would like to make a setting to insert article ID in backend.
The scenario is: User can click on a button, window with article list will appear, than can choose the article. Article ID will be stored in component config.
Than I can populate article in frontpage (this part I know)
You need to do the following:
Add path to joomla content article element
Create instance of that element
Display it
`
<?php
// I created the element inside of the view, $this is my View.
// It can be model/view/controller. Does not matter
// Include Element
require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'elements' . DS . 'article.php';
// Create Instance
$articleElement = new JElementArticle($this);
// Output article
echo $articleElement->fetchElement('article', 0, $this, 'myparam');
// NOTE: name of article_id element will be myparam[article]
?>
If you want to change the way element looks, you need to overload/modify element. It is pretty easy to do, you can copy site/administrator/components/com_content/elements/article.php, make changes and you will get your own version of element. Do not modify article.php component, you will mess up things for Joomla and if you plan updating your site in future... you'll loose changes after update.

Resources