@Janjetina
as your pleasure... this will add your both Cover image for your article and can add picture to your article content
first of all you need
Ckeditor and Ckfineder(it's demo but fully function)
google will help you find it.
Then, put your Ckeditor and Ckfinder folder to your root dir and open your editarticle.php
in your <head> tag add
<script type="text/javascript" src="js/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
and
<script type="text/javascript">
window.onload = function()
{
CKEDITOR.replace('content',
{
filebrowserBrowseUrl : '/ckfinder/ckfinder.html',
filebrowserImageBrowseUrl : '/ckfinder/ckfinder.html?Type=Images',
filebrowserFlashBrowseUrl : '/ckfinder/ckfinder.html?Type=Flash',
filebrowserUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
filebrowserImageUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
filebrowserFlashUploadUrl : '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
});
};
</script>
that is simple setup for Ckeditor and Ckfinder
now go to your form add this code before form
<script type="text/javascript">
function BrowseServer()
{
var finder = new CKFinder();
finder.basePath = '/ckfinder/';
finder.selectActionFunction = SetFileField;
finder.popup();
}
function SetFileField( coverimage )
{
document.getElementById( 'coverimage' ).value = coverimage;
}
</script>
and add id="content" in <textarea name="content" /*add here*/></textarea>
and add new input element
<li>
<label for ="coverimage">Cover Image:</label>
<input id="coverimage" class="edit" name ="coverimage" type="text" value="<?php echo ( $results['article']->coverimage )?>"/>
<input type="button" style=" margin-left: 10px; padding: 5px;" value="Browse Image" onclick="BrowseServer();" />
</li>
------------------------
now we will move to work with Class file open it
and add
public $coverimage = null; // around top most to define our var
//and skip to construct function add
if ( isset( $data['coverimage'] ) ) $this->coverimage = $data['coverimage'];
//then go to insert function and modify $sql line
$sql = "INSERT INTO articles ( publicationDate, title, summary, content, category, coverimage ) VALUES ( FROM_UNIXTIME(:publicationDate), :title, :summary, :content, :category, :coverimage )";
//and add
$st->bindValue( ":coverimage", $this->coverimage, PDO::PARAM_STR );
// before
$st->execute();
//last do similar to update function but just add
coverimage=:coverimage into $sql line (before WHERE)
now we're almost done
go to your database and add new column
coverimage VARCHAR 255 not null
it might work now.
to add image in your article just add by use button in Text Editor
and click "brows serve" to upload and select
to add cover just click "Brows Sever" and file path will store in to your database
----------------------
move to front-end , index.php
in foreach add
<div id="a-cover"><img src="<?php echo $article->coverimage ?>" alt="cover image"></div>
now you have both Cover image and image in articles content.
PS. let's me know if you confuse or have any problem
[Edit - only spell check

]
[Edited by chotikarn on 22-Feb-12 10:25]