Forums

A few problems displaying text and pictures

bristolcat 27 Jun, 2009
I recently used CC to connect to a form and am really impressed with how it works so far. I've got a few problems that I cannot clear up, however, even after a few days of doing nothing but troubleshooting my site.

This form collects basic information about people - things like name, e-mail and hometown. There are also two fields (textareas) intended for long fields of text and a file upload for a picture. In ChronoConnectivity, I have it set up so that this data is instantly added to a table which displays everything neatly.

The biggest problem I've run into is how the images behave when they are added into the table. The file upload field is named "file_8" and I can call the picture using {file_8}. Unfortunately, if someone completes the form without uploading an image, Internet Explorer insists on trying to open an image anyway, leaving me with a big box and a red x. This is unacceptable, so I would like to learn how I can either not display the image link if the field is empty or have these empty fields automatically go to a default placeholder image. Requiring an image is not an option.

I really thought it wouldn't be so hard. I tried to run if file_exists on it, but it seems to either see the fields all as empty or all full, depending on how I access the information. I've tried several ways to get it to differentiate between an empty field and a field with a filename in it, but no luck so far.

I also have a concern about the image size. I installed the image resize plugin that I found here on the forums, but it seems to be somewhat out of date and brought up errors in IE. I commented some code out of the plugin and the images do resize, but it's still throwing up some errors. I can discuss that later, as it's not my main concern right now. For now, I have a width set to the image in the table, which seems to be working.

Finally, I'm struggling to get the textarea fields the way I need them to be. I had been struggling with a 250 character limit which I couldn't seem to overcome, but discovered that was a setting that I could edit in the database, via phpMyAdmin. Now the problem lies in the fact that the text's formatting seems to get stripped. I don't need fancy fonts, sizes, colors of any of that. I don't need to edit it from the front end. What I do need it to do, however, is retain its line breaks and paragraph tags. It hasn't been doing that, and when it's displayed in the table, the neat paragraphs that I submitted get thrown into one big lump of unreadable text.

I've been working with CF and CC for two and a half straight days, trying to solve these problems. I'm not the best with PHP, but I'm trying. Hopefully someone can offer me some answers or advice- it would be very much appreciated! Thanks!!!
bristolcat 28 Jun, 2009
I'm desperate for some help, as the more I work with this, the dumber I feel!🙂

I've come to the conclusion that I do not know how to correctly get information from the database. And since it's so specific to Chronoforms, I figure that the best place to ask is here.

So, say that I added a dropdown box to my form. Basically, the options are "Upload picture," "Mail picture" and "Do not submit picture" with the respective database fields listing "upload," "mail" and "none." I should be able to display or not display the uploaded picture based on this data. Something like

if select_1 equals "upload" display image url
else if select_1 equals "mail" echo "Picture coming soon!"
else if select_1 equals "none" echo "No picture submitted."

I have no idea how to write that PHP code. I mean, I do, but trying to get the information out of the database so that I cna do things with it, has proven difficult to me. I've been going through the forums like crazy, and I found a lot of people drawing info from the database - I tried using their code to call variables, but it never seems to work for my setup, and I'm not sure how to achieve that. I'm not sure how to attack the "equals" part, either. There seems to be any number of methods for that, depending on what your data is.

My info:
database name: jos_chronoforms_alumni
dropdown name: select_1
image filename field: file_8

I also haven't figured out the textarea formatting problems yet, if anyone has any ideas there. I see lots of things about it here in the forums regarding forms, and supposedly it was fixed in the latest release, but nothing about Connectivity. :?

Thanks!!!
bristolcat 28 Jun, 2009
Leave it to me to post on a forum about how dumb I am and then figure out the problem!

I was trying to get the information out of the database by using

$row->select_1

But according to this page (http://www.chronoengine.com/forums.html?cont=posts&p=34405&f=6#p34405) on the forum (that just had not been coming up in searches at all until now), it should be...

$MyRow->select_1

...for the new Connectivity.

So, if you're curious as to how I did it, I had a dropdown that looked like this:

<div class="form_element cf_dropdown">
    <label class="cf_label" style="width: 150px;">Select a picture submission option</label>
	<select class="cf_inputbox" id="select_1" size="1" title=""  name="select_1">
            <option rel="none" value="">Choose Option</option>
            <option rel="morealumni1" value="upload">I would like to upload a picture</option>
            <option rel="morealumni2" value="mail">I would like to mail you a picture</option>
            <option rel="none" value="decline">I do not wish to post a picture</option>
        </select>
    <div class="cfclear"> 
    </div>
</div>

Please note that the "rel=" tags that I have in there are related to a javascript method I used to hide certain form fields unless a specific dropdown option was selected. The method and file I used can be found here: http://www.quirksmode.org/dom/usableforms.html

In Connectivity, I utilized this content to either display an image file upload or assorted messages according to what was picked from the dropdown. I put this right into the body:

<?php $select_1 = $MyRow->select_1;
    if (preg_match("/upload/i", "$select_1")) {
        echo "<img src='http://www.sfc1999.com/components/com_chronocontact/uploads/alumni/{file_8}' width='400' >";
    } elseif (preg_match("/mail/i", "$select_1")) {
        echo "<div style='width: 400px;'><h3>Picture coming soon!</h3></div>";
    } else {
        echo "<div style='width: 400px;'><h3>No picture submitted</h3></div>";
    }
?>

So far it seems to work. I hope that it's the correct way to do this - I'm not a PHP programmer and it's been a struggle to understand what is going on. I'm going to try to use similar PHP code to hide a maiden name field that may or may not be blank. We'll see!

Still trying to figure out the text area formatting if anyone has any advice. Thanks!!!
Max_admin 30 Jun, 2009
Hi bristolcat,

Please tell me what are the problems you have right now exactly ?🙂

Regards
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.