• Resolved Conny

    (@conny64)


    Hi,

    I would be happy if you are logged in to the frontend, that you can see a link under the table with which you can easily edit the CSV file.

    I have realized this with the following PHP script. (only example)

    <?php
    $file = "test.csv";
    echo "Editor (dieser Menüpunkt wird nur angezeigt wenn man im Backend angemeldet ist)";
    
    //* SPEICHERN
    if ($_POST["auswahl"] == "Speichern") {     file_put_contents($file, stripslashes( $_POST['editor'] ) ); 
    echo "Gespeichert !";}
    
    //* INHALT AUS DATEI EINLESEN$
    content = stripslashes( file_get_contents($file) );
    ?>
    
    //* Formular anzeigen
    <form action="/konfiguration" method="post">
    <p><textarea name="editor" rows="20" cols="120">
    <?php echo htmlspecialchars($content); ?></textarea></p>
    
    <p><input type="submit" name="auswahl" value="Speichern" />	<input type="submit" name="" value="Abbrechen" /></p></form>
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author wibergsweb

    (@wibergsweb)

    Hi there!

    If I understand you correctly you would show the table as normal data, and then when you click a link, you want to show the same table as an editable table?

    If this is the case, I would consider some solutions (from easiest to hardest)

    Solution 1 (easiest)

    1. Create a page with the editable table.
    2. Create a page with a ordinary view of the table with a link to the page with the view of the editable table

    Solution 2 (requires Javascript)

    1. Load two different html-tables but with the same data, one that shows ordinary and one that is hidden.
    2. Toggle visiblity between these both tables when you click on the link (controlled by javascript)

    Solution 3 (requires PHP skills):

    1. In the link that have under the table, add something like ?editable=yes and in the php-code you check if editable is set to yes, and based on that show editable table (no = not editable ofc)

    Solution 4 (requires javascript/PHP skills)
    1. When you click on the link, fetch data from data through php: e.g. $html = $csvtohtmlobj->source_to_table( $arr ); ($arr includes settings)

    2. Update a specific html-element based on returned data in above step 1

    Plugin Author wibergsweb

    (@wibergsweb)

    I’m not implementing this kind of functionaltiy in the plugin because it would be too complex to make the codebase generic. But I hope above solutions might point you in the right direction!

    Plugin Author wibergsweb

    (@wibergsweb)

    No further questions now so I mark this as resolved. If you have questions later on, don’t hesitate to ask agan ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Simple online CSV Data Editor in fontend’ is closed to new replies.