Load a file from a xml string ?

For Joomla! 2.5 Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general
Note: All 1.6, 1.7 and 3.5 releases have reached end of life and should be updated to 3.x.

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Locked
duddy67
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 229
Joined: Sun Jul 12, 2009 12:04 pm

Load a file from a xml string ?

Post by duddy67 » Mon Apr 23, 2012 8:21 pm

Hi,

In order to add some customized fields in the user form I builded
a profile plugin as described here
http://docs.joomla.org/Creating_a_profile_plugin

So in the onContentPrepareForm function, When I load my form from the xml file (profiles/profile.xml) it works right.

Code: Select all

JForm::addFormPath(dirname(__FILE__).'/profiles');
    $form->loadFile('profile', false);
but for some reasons I'd need to build some part of the form on the fly so
I tried to store the content of the xml file in a php variable:

Code: Select all

$myprofile = '<?xml version="1.0" encoding="utf-8"?>
                 <form>
	            <fields name="myprofile">
		           <fieldset name="myprofile"
			           label="PLG_USER_MY_PROFILE_SLIDER_LABEL" >

                      ...
         
                  </form>';
then load it:

Code: Select all

$form->loadFile($myprofile, false);
but the form is not loaded at all.

Can someone tells me where the problem comes from ?


Thanks

duddy67
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 229
Joined: Sun Jul 12, 2009 12:04 pm

Re: Load a file from a xml string ?

Post by duddy67 » Tue Apr 24, 2012 11:14 am

I got it.
Finally the solution was simple.
Just using load function instead loadFile.


Locked

Return to “Joomla! 2.5 Coding”