Forums

How does one keep form entries from auto publishing?

mwcourtney 04 Jan, 2011
I have setup a form and made the necessary connections and displays with ChronoConnectivity all is fine there. What I do not understand is how can I limit the submitted form data from displaying until admin approval? For example: I want to be able to have all submitted form data unpublished by default. Once Admin gets the email of a submission they go to back-end and publish the data collected from the form.

Could someone please explain how to do this?

Thank you
GreyHead 04 Jan, 2011
Hi mwcourtney,

[list]
  • Add an extra column to the database for 'approved' and filter the displays to only show approved records.
  • Create a second mini-form to allow the Admin to view the records and approve it. Just needs a checkbox or radio button and a submit button (you could also do this from links in the email but that's a bit more complex).
  • [/list]

    Bob

    PS I prefer to keep this kind of admin in the front-end of the site and protect the 'admin' forms by checking user ids.

    Bob
    mwcourtney 08 Jan, 2011
    Thank you for the reply.

    What I really want to do is use the "published" field in my db table from the back-end. I have managed to get this column to display in the back-end data view of CC, however, when a record is set to unpublished it does not hide the record from my front-end listing. How is this supposed to work?

    Another thing I have tried in the WHERE SQL box is (WHERE `published` > 0), this works, however, I have applied your "Dynamic filters for your listing 1" tutorial to filter my records and the (WHERE `published` > 0) this seems to conflict with your tutorial code when a filter string is submited. My php knowledge is almost nill, but, I have been trying to figure this out as best I can. I would really like this to work any guidence would be greatly appreciated.

    Thanks
    GreyHead 09 Jan, 2011
    Hi mwcourtney,

    You are almost there. You need to include this test in the WHERE box along with the other tests. Probably adding
    $where[] = '`published` > 0';
    just after the $where = array(); line will do it. If not, please post the filter code you are using and I'll show you how to add it.

    Bob
    mwcourtney 09 Jan, 2011
    Thank you for all your help, but, I am sill having trouble.
    I not sure where to place ($where[] = '`published` > 0';).

    Here is my code:

    WHERE box:
    <?php
    $title = JRequest::getString('title', '', 'post');
    if ( $title ) {
    echo " WHERE `state` LIKE '%$title%' OR `city` LIKE '%$title%' ";
    }
    ?>


    Header box:
    <?php
    // get the number of records returned
    $db =& JFactory::getDBO();
    global $count;
    $count = $db->loadResult();
    
    $script .= "
    $('clear').addEvent('click', function() {
    $('title').value = '';
    });
    ";
    $doc =& JFactory::getDocument();
    if ( $script ) {
    $script = "window.addEvent('domready', function() { $script });";
    $doc->addScriptDeclaration($script);
    }
    if ( $style) {
    $doc->addStyleDeclaration($style);
    }
    // get the previous filter string
    $title = JRequest::getString('title', '', 'post');
    ?>
    
    
    <!-- start the listing table -->
    
    <table>
    <thead>
    <tr>
    <th><h2>Support Group Listings</h2></th>
    </tr>
    <tr>
    <th><strong>Listings are sorted alphabetically ascending by state/province and then by city.</strong></th>
    </tr>
    
    <tr><td>
    <br />
    
    
    <!-- display the filter box and buttons -->
    
    <input type='text' name='title' id='title' value='<?php echo $title; ?>' /> <input type='submit' name='filter' id='filter' value='Filter by State/Province or City' /> <input type='button' name='clear' id='clear' value='Clear' />
    
    <?php
    // check if there are any records returned
    if ( !$count ) {
    // no records - show the message
    echo "<div>Sorry, no results were found.</div>";
    } else {
    // some records, show the header & footer rows
    ?>
    
    </td></tr>
    
    <tr><td><div align="right"><strong><u>{new_record}</u></strong></div></td></tr>
    
    </thead>
    
    
    <?php
    }
    ?>
    
    <tbody>


    Body box:
    <tr><td><h2>{state}</h2></td></tr>
    <tr><td><strong>City: </strong><br />{city}</td></tr>
    <tr><td><strong>Country: </strong><br />{country}</td></tr>
    <tr><td><strong>Support Group Name: </strong><br />{sg_name}</td></tr>
    <tr><td><strong>Location: </strong><br />{location}</td></tr>
    <tr><td><strong>Time & Dates: </strong><br />{time_date}</td></tr>
    <tr><td><strong>Description: </strong><br />{description}</td></tr>
    <tr><td><strong>Contact: </strong><br />{contact}</td></tr>
    <tr><td><div align="right"><strong><u>{edit_record}</u>  <u>{delete_record}</u></strong></div></td></tr>
    <tr><td><p style="background-color: #014881; width: 400px; height: 2px;"></p></td></tr>


    Footer box:
    </tbody>
    </table>
    
    <?php
    // get the row count and show the pagination if needed
    global $count;
    if ( $count ) {
    ?>
    
    {pagination}
    
    <?php
    }
    ?>
    
    


    Again thank you for all your help.
    I am determined to get this working.
    GreyHead 09 Jan, 2011
    Hi mwcourtney,

    Please change the WHERE box code to
    <?php
    $where = array();
    $where[] = '`published` > 0';
    $title = JRequest::getString('title', '', 'post');
    if ( $title ) {
      $where[] = "`state` LIKE '%$title%' OR `city` LIKE '%$title%' ";
    }
    if ( count($where) ) {
      echo " WHERE ".implode(' AND ', $where);
    }
    ?>
    You can use this idea to link together a series of WHERE clauses.

    Bob
    mwcourtney 09 Jan, 2011
    That worked!

    Thank you so much.
    This topic is locked and no more replies can be posted.