HTML text do not appear in the correct place after editing the PHP code? HELP!!!

HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Ivan Gashtilov -
Number of replies: 17

Hi,

Can you help me with a problem i have. I have added the Category "Terms and Conditions" as shown in the image bellow circled in green in the signup_form.php with the following code:

$mform->addElement('header', '', get_string('termsandconditions'), '');

When i put my HTML code below...

echo "<ul>\n";

echo "<li>By completing this registration form you are protected by and agree to <a href=\"http://www.________________.co.uk\">The __________________.co.uk terms and conditions</a></li>\n";

echo "<li>Your personal information will not be provided to any third party without your permission.</li>\n";

echo "<li>Please contact the team at The _______________ at <a href=\"mailto:admin@________.co.uk\">admin@______.co.uk</a> if you have any questions or comments.</li>\n";

echo "</ul>\n";

...my text appears at the top of the screen above the Logo of the page. I have included a screenshot to clarify what i mean below. Note that the text circled in red is the text i am talking about, and circled in green, is the custom made category i coded into the signup_form.php.

How can i move that text to appear inside the custom made "Terms and Conditions" box?

img

Average of ratings: -
In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Mary Cooch -
Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators

Hi Ivan - I have moved your question to the Themes forum as you might get more specialised help there. Unfortunately I cannot see your screenshot as my school filtering system has blocked it. Thankyour for your private message but I am sorry I cannot help you even though you said your needs are very urgent asap, because I do not understand much Moodle code. I hope someone will come to your aid here shortly.

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Ivan,

Which version of Moodle are you using? The form you have is noting like the one I have in Moodle 1.9.9 so I am guessing your's is an older version of signup_form.php?

Mary E

 

In reply to Mary Evans

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Ivan Gashtilov -

nope - i am also using 1.9.9, but that whole form is custom modified by me with a lot of code swapping and new fields.

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

In that case you are on your own in this, as changing Moodle core files is not recomended.

It would have been far better if you had done this in the theme, by creating a custom php file called something like mytheme-signupform.php and then use <?php include('mytheme-setupform.php') ;?> somewhere in the header.html.

Mary

In reply to Mary Evans

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Ivan Gashtilov -

I appreciate your honesty, Mary, but that was the only way i could manage to get exactly what was required of me. Besides i havent changed anything, apart from swapping several lines of code, and the others are still there, just commented with the "/*    */", so that they are not considered in the code execution. I would've created a new php file in the theme section, but i am a beginner with PHP, and thats why i decided not to do that, since it would have taken me far far longer to do the form that way.

But i think that your comments slightly divert from the original question I asked which was how could i place the text circled in red within the box circled in green?

If that would help i can copy the whole signup_form.php code (the way i have formatted it) here

Regards

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

The problem with changing core files is probably your downfall with this now. The fact you are only learning PHP is doubling your probelm too.

I'm a novice at this, but I did see some odd notation in your code.

What is \n used for at the end of the line? Never come accross that before.

What you have as an unordered list looks ok and it looks ok too evem if it is in the wrong position. However, in commenting out the original code you may well have lost the structure of the form, or failed to continue the structure of it in some other way. But how to get it to it's right position within the boundary of the Terms & Conditions box I have no idea without seeing the whole php file. So yes please upload it here as an attachment.  And I'll see what I can do.

Thanks

Mary

In reply to Mary Evans

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Ivan Gashtilov -

Dear Mary,

Once again I would like to thank you for looking into my problem.

that "\n" i am not quite sure what it is, as i typed the HTML code myself, and then used a HTML --> PHP converter to be able to convert it. I know that this was not a good idea... in fact - a very bad idea, but I am in the position to just try everything in order to make it work.

I have attached the file so please have a look at it, and i will be extremely thankful if you manage to solve my mystery.

Cheers

Ivan

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Ivan,

I'll take a look at this sometime today and get back to you later.

The \n is a line break, but will not work in html or xhtml so you would normally need to add a <br /> for a line space, but in your case  <\ul> and </li> are pre set to sit on a seperate line unless set differently in css mark-up using  ul li {display: inline}

So the \n is not needed so you can take it out.

Acctually it's easier to hand code PHP yourself rather than rely on a converter as you can't be sure its not adding things you don't really need or want in the code. Besides you learn more doing it yourself.

Cheers

Mary

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Ivan Gashtilov -

Mary,

I have removed the "\n" from my code...still did not fix the layout, but i hope that you will be able to tell me more later on when you see the php file.

Regards,

Ivan

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Amit Gupta -

Hi Ivan,

I hope your problem is solved in the attached file. I have done some changes to fix your problem.

Cheers

Amit

Average of ratings: Useful (1)
In reply to Amit Gupta

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Amit,

Thanks you for coming to the rescue. Now I have learned something too! smile

Cheers

Mary

In reply to Amit Gupta

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Ivan Gashtilov -

Hi Amit,

Thank you very much for that...it worked and i cant tell you how happy i am. smile

And like Mary, I now learned a new thing - how to do the HTML integration in PHP, and i am sure that this will help me in future smile

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Amit Gupta -

Hi Ivan,

I am happy to make you happy smile

Just to correct you, the method I have used to include HTML is specific to Moodle only. smile

Amit

In reply to Amit Gupta

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Ivan Gashtilov -

>>>I am happy to make you happysmile

LOL for someone who reads this part of the reply without reading the whole story behind it, will start thinking some weird stuff ... hahahahaha

But serious now - if this is specific to moodle only, how would i put HTML within PHP usually? Do i use the echo function? or is there another specific way?

Thanks again

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Amit Gupta -

ha ha ha

yea in PHP there are many ways to put HTML

1. echo

2. print

3. close the php tag<?php php code here ?> HTML here <?php php code here ?>

The Moodle framework must be using first method only to put HTML in the core. addElement is just a method Moodle is providing generate HTML. Checkout below link for more details on this method:

http://docs.moodle.org/en/Development:lib/formslib.php_Form_Definition#addElement

In reply to Ivan Gashtilov

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

In Moodle 2.0 I've been learning how to use a rather clever way of writing html in php. This is similar to the m.form in your original problem.

This is an example from a theme I'm currently building in Moodle 2.0...

<?php if (isloggedin()) {
echo html_writer::start_tag('div', array('id'=>'profileblock'));
echo html_writer::tag('h1', get_string('usergreeting', 'theme_flowerpower', $USER->firstname));
echo html_writer::start_tag('p', array('class'=>'pre-login'));
echo html_writer::link(new moodle_url('/login/logout.php', array('sesskey'=>sesskey())), get_string('logout'));
echo $PAGE->headingmenu;
echo html_writer::end_tag('p');
echo html_writer::end_tag('div');
} else {
echo html_writer::start_tag('div', array('id'=>'profileblock'));
echo html_writer::start_tag('div', array('id'=>'post-login'));
$loginlink = html_writer::link(new moodle_url('/login/'), get_string('loginhere', 'theme_flowerpower'));
echo html_writer::tag('h1', get_string('welcome', 'theme_flowerpower', $loginlink));
echo $OUTPUT->lang_menu();
echo html_writer::end_tag('div');
echo html_writer::end_tag('div');
} ?>

It's all very exciting stuff. smile

Cheers

Mary

In reply to Mary Evans

Re: HTML text do not appear in the correct place after editing the PHP code? HELP!!!

by Ivan Gashtilov -

thanks to both of you guys... you have both supplied me with helpful info! wink