• Resolved madebyj

    (@madebyj)


    Dear Tobias,

    First of all, thank you very much for your plugin. I am just starting with it but I can see how powerful it is 🙂

    I have some data from endusers I would like to restitute in a dynamic way. Let’s say a user A has 3 cars (mercedes, dacia, renault) and a user B has 2 cars (alfa, bmw).

    My goal is to achieve a page loaded by a connected user which display only his own data.

    1 – I am creating a table with a header line and a body line. I fix values of the header line (cars).
    2 – I insert my php code in the body line

    How can I set things so a new line is automatically created after each entry ?

    In that way :

    User A :
    Cars
    mercedes
    dacia
    renault
    User B :
    Cars
    alfa
    bmw

    Thank you very much for any help you can provide. Hope it works 🙂

    Ben

    PS : I also had the issue PHP not loading without the instruction convert_line_breaks=false. Just in case it helps you 🙂

    https://wordpress.org/plugins/tablepress/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I’m not really sure if I understand. You will probably just have to print that new line by printing the HTML <br /> tag.

    Regards,
    Tobias

    Thread Starter madebyj

    (@madebyj)

    Dear Tobias,

    By using <br> I come up with a single line. So to get back to my example. I will have :
    User A :

    line 1 (header) Cars
    line 2 (body) mercedes
                  dacia
                  renault

    I am loosing “sort” functionnality for e.g. as I have all my data in the same line.

    I am looking for this result :
    User A :

    line 1 (header) Cars
    line 2 (body) mercedes
    line 3 (body) dacia
    line 4 (body) renault

    I hope it is clear 🙂

    Ben

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi Ben,

    ah, ok. So you want to create real table rows here.
    To be honest, I don’t really see the point of using TablePress here then. Instead, just use your PHP code to render the full HTML table.
    You can then simply use the DataTables JS library for the sorting directly (that’s the library that TablePress uses). See http://next.datatables.net/ for information on that.

    Regards,
    Tobias

    Thread Starter madebyj

    (@madebyj)

    Dear Tobias,

    You are right and it worked for me but there is something I do not understand. Maybe you have an easy answer to that…

    Tablepress plugins is installed on my wordpress but if I want to use function of DataTables, I have to load all the libraries. Is it not strange ?

    I have tried a lot of diferent ways (header, enqueue etc.) and the only way I found out is to write this at the begining of my wordpress page:

    <link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.0-rc.1/css/jquery.dataTables.css"><script type="text/javascript" charset="utf8" src="//code.jquery.com/jquery-1.10.2.min.js"></script><script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.0-rc.1/js/jquery.dataTables.js"></script>

    Maybe you can advice me on this.

    Also TableTools is not showing…

    <script>
    $(document).ready( function () {
        $('#sommets').DataTable({
    		"sDom": 'T<"clear">lfrtip'
    	} );
    } );
    </script>

    Thank you for your help 🙂

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    you don’t really have to load all the libraries from an external source, you can also include the ones that TablePress ships with.

    Using a custom wp_enqueue_script call should be the best here, for independence from TablePress.

    Regards,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PHP in table to load data dynamically. How does it work ?’ is closed to new replies.