PDA

View Full Version : [Pending] Not Require an image Icon


ptmuldoon
02-21-2005, 03:44 PM
I went to submit my first article, and I'm being told that I have to include an image icon. I looked in the admin settings, and I have selected No for "Use Category Icons"

Is there a way to submit articles that don't have an image icon?

Also, not a big deal, but after not having an image icon, and if you hit the back button on your browser, you lose your article, and have to re-enter the entire thing. Not that big a deal, but a little annoying. That could be my brower though. I'm using mozilla.

I know enough about php to generally be able to find and understand the code a little bit, but at same time to do series damage. So looking at the code in the artcles.php file, I've found this
$path = $path.'/';
if (is_uploaded_file($icon['tmp_name']))
{
if (file_exists("$path" . $icon['name']))
{
eval(print_standard_error('vbart_filealreadyexists '));
}

$result = copy($icon['tmp_name'], "$path" . $icon['name']);
if (!$result)
{
$error = ob_get_contents();
eval(print_standard_error('vbart_errorwriting'));
}

$newpath = $vbart_options['vbartartimgpathab'].$artid."/";
$iconpath = $newpath.$icon['name'];
echo '<p>'.$vbphrase['vbart_imguploadsuccess'].'</p>';
$DB_site->query("UPDATE " . TABLE_PREFIX . "articles_article SET icon='$iconpath' WHERE articles_articleid='$artid'");
}
else
{
eval(print_standard_error('vbart_invalidfile'));
}

Now, what I'm thinking is to edit that code to first look if the user supplied an image for the article. If they did, then upload and use that image with the article. But if they did not provide an image, then the script would use a default image that on your server, likely in the default folder where your article images will go.

So is this possible? I think it may just be a matter of either altering the above code, or adding in another if/else command. I hope I'm on the right track at least.

cinq
02-22-2005, 12:23 AM
Yep you're right, you remove the else clause in the code above. But I will not offer support if anything goes wrong.
I intended all articles to have icons to make the layout uniform. :)

ptmuldoon
02-22-2005, 12:47 PM
Well, I'm not thinking of removing the else clause, but to expand upon it. If I understand everything, images are placed in an images/articles/5/ folder, with a new folder number being added for each article submitted.

So I'm thinking you place a default.gif in your images/articles folder.

Then you add in an additional elseif above the else clause. Now, when a user submits an article, first it will look for the user submitted image. If thats not there, it will look for the default.gif to use. And if it can't find either, to give you the error message of no image found.

Again, I know just enough about php to be dangerous and mess something up. But I'm going to give this a shot tonight when I get back to my home pc, and take a look at my php intro books that I have.

mr.gamesbay
02-22-2005, 03:01 PM
Agree, the should be a default gif, if someone t want to upload a articles picture.

jluerken
02-22-2005, 03:31 PM
Agree, the should be a default gif, if someone t want to upload a articles picture.

Yes thats a really good idea.

ptmuldoon
02-22-2005, 04:49 PM
Also, Just as an FYI, that I noticed that although if you didn't include an image, that the article is still actually being submitted, as I see it waiting for approval in the admin panel. I'll see if I can understand any of the code enough to add elseif command for a default pic, but I think I'm going to really mess it up. Somebody with better coding skills may want to do it as well.

mr.gamesbay
02-23-2005, 03:33 AM
Also, Just as an FYI, that I noticed that although ifyou didn't include an image, that the article is still actually beingsubmitted, as I see it waiting for approval in the admin panel. I'llsee if I can understand any of the code enough to add elseif commandfor a default pic, but I think I'm going to really mess it up. Somebodywith better coding skills may want to do it as well.

Yes,yesterday a user submits 9 Times the same Article, he didn?t know whatmissing and what is wrong. I turn this mod offline, I hope there will be a fix.

ptmuldoon
02-23-2005, 11:35 AM
i crashed and bombed at trying to understand how to add in the code. Perhaps Cinq can take a look at it when he gets a chance, or add this into the future requests.

cinq
02-25-2005, 02:57 AM
This will go in as a feature in the next revision so don't bother with messing around with the code, unless you need it urgently.