Page 1 of 1
Using Udemy Course, but with a little trouble
Posted: 2022-01-17 23:32
by arcanebits
Hi, im making some use of the udemy course, and im stuck in the creation of a simple button via hooks, this is my code
AFAIK this should work but the Appgini App doesnt show the "Contrato" Button, it acts as nothing happened
function ep_dv($selectedID, $memberInfo, &$html, &$args) {
if (isset($_REQUEST['dvprint_x'])) return;
ob_start(); ?>
<script>
$j(function(){
$j('#ep_dv_action_buttons .btn-toolbar').append(
'<div class="btn-group-vertical btn-group-lg" style="width: 100%;">' +
'<button type="button" class="btn btn-success btn-lg" onclick="">' +
'<i class="glyphicon glyphicon-ok"></i> Contrato</button>' +
'</div>'
);
})
</script>
<?php
$form_code = ob_get_contents();
ob_end_clean();
}
Any Tip? or if im doing some wrong?
Aldo
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 06:52
by pbottcher
Hi,
you need to add the code to the html.
Try after the ob_end_clean();
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 14:17
by arcanebits
Thanks for the quick reply! Im a C# coder, some quite basic/general html/php knowledge.
$html.=$
nameofmy_formcode
im right?
Aldo
pböttcher wrote: ↑2022-01-18 06:52
Hi,
you need to add the code to the html.
Try after the ob_end_clean();
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 14:27
by jsetzer
pböttcher's answer looks absolutely perfect.
Did you try? Doesn't it work? Is there any error message?
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 15:44
by arcanebits
It didnt for me: this is my piece of code, i placed the code (hopefully right) as you mention.
function ep_dv($selectedID, $memberInfo, &$html, &$args) {
if (isset($_REQUEST['dvprint_x'])) return;
ob_start(); ?>
<script>
$j(function(){
$j('#ep_dv_action_buttons .btn-toolbar').append(
'<div class="btn-group-vertical btn-group-lg" style="width: 100%;">' +
'<button type="button" class="btn btn-success btn-lg" onclick="">' +
'<i class="glyphicon glyphicon-ok"></i> Contrato</button>' +
'</div>'
);
})
</script>
<?php
$form_code = ob_get_contents();
ob_end_clean();
$html.=$j;
}
jsetzer wrote: ↑2022-01-18 14:27
pböttcher's answer looks absolutely perfect.
Did you try? Doesn't it work? Is there any error message?
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 16:16
by jsetzer
Did you really try with the code given to you? Your code is different, still. There is no declaration of PHP variable
$j
and you are not appending contents of
$form_code
PHP variable to
$html
variable.
Maybe you should start with a basic boilerplate and ensure you get this working before trying more complex ideas:
Code: Select all
function ep_dv($selectedID, $memberInfo, &$html, &$args) {
ob_start();
?>
<script>
$j(document).ready(function() {
alert('hello world');
});
</script>
<?php
$form_code = ob_get_contents();
ob_end_clean();
$html .= $form_code;
}
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 16:29
by arcanebits
Nice, thanks, and you are right, im going to comment out and place a hello world first to ensure touching even the right files, come back in a couple of minutes.
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 16:55
by arcanebits
To ensure im on the right direcotry I renamed main directory in the FTP and sends the expected error.
The end of the file in browser is: /ep_view.php so I guess im not barking to the wrong tree. Still nothing happens. Here is code
function ep_dv($selectedID, $memberInfo, &$html, &$args) {
ob_start();
?>
<script>
$j(document).ready(function() {
alert('hello world');
});
</script>
<?php
$form_code = ob_get_contents();
ob_end_clean();
}
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 16:56
by arcanebits
Im quite sure im missing some quite ovious...
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 17:12
by arcanebits
I placed a snapshot here, maybe there is some weird thing going on

Image not appearing, here is a naked link
http://www.edufione.edufisoft.com/share ... rror01.jpg
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 17:14
by jsetzer
You once again and still don't append
$form_code
to
$html
variable, as we have already written a couple of times. It would be very helpful if you could just copy & paste exactly what we are giving to you.
Your code:
<?php
$form_code = ob_get_contents();
ob_end_clean();
}
Suggested code:
Code: Select all
<?php
$form_code = ob_get_contents();
ob_end_clean();
$html .= $form_code;
}
It seems I am not able to help you. Maybe my English is not good enough, I'm sorry.
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 17:15
by jsetzer
Your uploaded image is not visible - at least I cannot see it.
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 17:19
by jsetzer
arcanebits wrote: ↑2022-01-18 17:12
maybe there is some weird thing going on
Yes, maybe, but until we get to this unlikely case, for the moment you could just start by copying and then pasting the code given to you. This could become a game changer.
Re: Using Udemy Course, but with a little trouble
Posted: 2022-01-18 17:24
by arcanebits
It worked!,
Sorry for my repeated mistakes, is not about your english, quite sure it was my issue, please keep the help comming.
Since I got the hello world working, I place the button now?
Thanks for you help!
Aldo