Using Udemy Course, but with a little trouble

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
arcanebits
Veteran Member
Posts: 104
Joined: 2018-12-10 21:52

Using Udemy Course, but with a little trouble

Post by arcanebits » 2022-01-17 23:32

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

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Using Udemy Course, but with a little trouble

Post by pbottcher » 2022-01-18 06:52

Hi,

you need to add the code to the html.

Try after the ob_end_clean();

Code: Select all

$html.=$form_code;
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

arcanebits
Veteran Member
Posts: 104
Joined: 2018-12-10 21:52

Re: Using Udemy Course, but with a little trouble

Post by arcanebits » 2022-01-18 14:17

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();

Code: Select all

$html.=$form_code;

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Using Udemy Course, but with a little trouble

Post by jsetzer » 2022-01-18 14:27

pböttcher's answer looks absolutely perfect.

Code: Select all

$html .= $form_code;
Did you try? Doesn't it work? Is there any error message?
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

arcanebits
Veteran Member
Posts: 104
Joined: 2018-12-10 21:52

Re: Using Udemy Course, but with a little trouble

Post by arcanebits » 2022-01-18 15:44

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.

Code: Select all

$html .= $form_code;
Did you try? Doesn't it work? Is there any error message?

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Using Udemy Course, but with a little trouble

Post by jsetzer » 2022-01-18 16:16

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;
}
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

arcanebits
Veteran Member
Posts: 104
Joined: 2018-12-10 21:52

Re: Using Udemy Course, but with a little trouble

Post by arcanebits » 2022-01-18 16:29

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.

arcanebits
Veteran Member
Posts: 104
Joined: 2018-12-10 21:52

Re: Using Udemy Course, but with a little trouble

Post by arcanebits » 2022-01-18 16:55

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();
}

arcanebits
Veteran Member
Posts: 104
Joined: 2018-12-10 21:52

Re: Using Udemy Course, but with a little trouble

Post by arcanebits » 2022-01-18 16:56

Im quite sure im missing some quite ovious...

arcanebits
Veteran Member
Posts: 104
Joined: 2018-12-10 21:52

Re: Using Udemy Course, but with a little trouble

Post by arcanebits » 2022-01-18 17:12

I placed a snapshot here, maybe there is some weird thing going on
Image
Image not appearing, here is a naked link http://www.edufione.edufisoft.com/share ... rror01.jpg
Last edited by arcanebits on 2022-01-18 17:15, edited 1 time in total.

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Using Udemy Course, but with a little trouble

Post by jsetzer » 2022-01-18 17:14

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.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Using Udemy Course, but with a little trouble

Post by jsetzer » 2022-01-18 17:15

Your uploaded image is not visible - at least I cannot see it.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

Re: Using Udemy Course, but with a little trouble

Post by jsetzer » 2022-01-18 17:19

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.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

arcanebits
Veteran Member
Posts: 104
Joined: 2018-12-10 21:52

Re: Using Udemy Course, but with a little trouble

Post by arcanebits » 2022-01-18 17:24

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

Post Reply