How to add Custom code to a component/admin view?

65 views
Skip to first unread message

Nico van de Kamp

unread,
Feb 8, 2020, 6:07:18 AM2/8/20
to Joomla Component Builder
Hello,

I have a few questions which I try to find out, but till now I did not succeed.

I have component with three admin views:
  • Department
  • Employee
  • DepartmentEmployee
These works for me fine.

First question:

But now I want to change the detail view of DepartmentEmployee but at which place do I need to add the code.

I hav add this peace of code: {echo "Add PHP (custom document script) *<br/>";} at the part "Add PHP (custom document script) *". But that is added at the method "setDocument".

So I thought I create a peace HTML of custom code.
  • But how can I add these, I mean what is the syntax of the call?
  • Where do I add or where can I put this call so that this part is added at the end of the detail DepartmentEmployee? 

Second question:

At the end of these detail page I want to do somenting with dataTables. Where do I put these library  in the JCB so that it is not lost when I compile the component again. :
{
<link rel="stylesheet" type="text/css" href="/DataTables/datatables.css">
<script type="text/javascript" charset="utf8" src="/DataTables/datatables.js"></script>}

Best regards,

Nico

Erik van Doorne

unread,
Feb 8, 2020, 11:18:57 AM2/8/20
to Joomla Component Builder, Nico van de Kamp
I would like to second the request made by Nico on dataTables code insertion. I use it extensively in projects currently not made with JCB and would like to know how to integrate this in JCB in the best possible way.

Thank you and best regards,

Erik.

--
You received this message because you are subscribed to the Google Groups "Joomla Component Builder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcb+uns...@vdm.io.
To view this discussion on the web visit https://groups.google.com/a/vdm.io/d/msgid/jcb/2d8e1905-82d7-47d9-a025-6faaaf2a1129%40vdm.io.

((ewe))yn

unread,
Feb 8, 2020, 1:16:23 PM2/8/20
to Joomla Component Builder
Greetings Nico

Most of the time if I want to add custom HTML to an Admin_edit_view I will use a note (text field) to do so. Yet JCB does allow for custom HTML to be added as a whole complete independent Tab in the view.

So adding a Note text field gives you the power to write text above or below other fields in the view. But if you want to do something more major you can add your own whole tab (in the adminview -> settings tab -> look for Admin custom tab)

Hope this helps, let me know.

Balearian Consulting

unread,
Feb 9, 2020, 5:12:33 AM2/9/20
to Nico van de Kamp, Joomla Component Builder
Hello Nico,

Referring to your second question, if you want your own external file(s) included in compiled component package, you have to use JCB’s custom folder (look for video instruction on how to use it because this is the key you are looking for), then you can add your custom php code to include them in the view (Add PHP (custom document script) ):
$doc = JFactory::getDocument();
$doc->addStyleSheet($urlToYourStyleSheet);
$doc->addScript($urlToYourJavaFile);

Hope it helps.

Best regards!

claudio

--
You received this message because you are subscribed to the Google Groups "Joomla Component Builder" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jcb+uns...@vdm.io.
To view this discussion on the web visit https://groups.google.com/a/vdm.io/d/msgid/jcb/2d8e1905-82d7-47d9-a025-6faaaf2a1129%40vdm.io.

Balearian Consulting

P  Per rispetto ambientale si prega di stampare solo in caso di assoluta necessità
P  Please consider the environment before printing this e-mail
 



Questo messaggio elettronico e ogni documento con esso inviato è da ritenersi confidenziale e deve intendersi ad uso esclusivo dei suoi destinatari. Se non siete il destinatario di questo messaggio siete cortesemente pregato di notificarcelo immediatamente a balearian...@gmail.com: non siete autorizzato a copiarlo o usarlo per nessuna ragione, né a divulgarne il suo contenuto ad alcuno in qualsiasi forma.
This electronic mail message and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, please notify us to balearian...@gmail.com immediately: you should not copy it or use it for any purpose, nor disclose its contents to any person.

Balearian Consulting CB

Questo messaggio elettronico e i suoi allegati sono stati controllati con anti-virus.
This electronic mail message and attachments have been swept for known computer viruses.







Nico van de Kamp

unread,
Feb 10, 2020, 5:27:42 AM2/10/20
to Joomla Component Builder
Hello,

Thanks for you're reaction.

Maybe I don't understand you're comment, but I'm satisfied about my detail screen so far. If do "new" than I can create a new record for the DepartmentEmployee table (admin  view). That is working with a dropdown for the employee's and I can select one. But I want to change this specific part around the employee so that it works as I think it should work for me (with dataTables).
The second part I want to change is the dropdown selection for department I want to change that with PHPAjax.

I can add code by myself at the setDocument function (or on another place) but than it is lost if I compile it again. I'm losing the power of JCB.

From my point of view feeling, I don't need a new Tab in the view. Or I do not understand how it is working also not after watching the video JCB custom folder.

I saw in one of the video tutorials that there are some free example projects/components, like the demo project. Unforunately I could not find these.

Are there more examples like demo project, so that I can see how things are configured, and need the be done and why things are done and more important WHEN things need to be done.

Best regards,

Nico


Op zaterdag 8 februari 2020 19:16:23 UTC+1 schreef ((ewe))yn:

o...@utsch.biz

unread,
Oct 24, 2020, 9:29:52 AM10/24/20
to Joomla Component Builder, Nico van de Kamp
Hi Nico,

did you get this to work finally? I had used footables but would rather want to use datatables instead and I have gone through the advice on how to integrate custom libs which I did with data tables. In the resulting header of my site view in which I want to use datatables I see that it's loaded, but I always get the error 

Uncaught TypeError: $ is not a function

from the line
$(document).ready(function() {...

when I want to call the datatable function.

I even isolated all in standalone html files trying many variations but I don't get it work. Any idea?

Oliver

mtj

unread,
Oct 26, 2020, 4:05:09 AM10/26/20
to Joomla Component Builder, o...@utsch.biz, Nico van de Kamp
Have you tried to substitute the $ with "jQuery"?
I'm not sure how this is in the backend, but in frontend jQuery cannot be used with its $-shortcut.
Reply all
Reply to author
Forward
0 new messages