Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Blog comments

  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Blog comments

    I want to implement a script on my site that would allow my users to add comments on my entries. The scripts that I have found on google have been to comment on the entire site, not per entry, or have needed javascript. I have an idea on how I would do it. Each entry would get an id that would correspond to the database, and then have each comment for that date be shown. But I don't know php/mysql well enough to do it.

    I would like it so when the user clicks add a comment, they are taken to a page with the form fields to fill in up top and the comments from other people below them. And another link with for view the comments which lists my entry and has the comments below it.

    So if anyone knows of one that uses php, mysql and no javascript, could you point me in the right direction.

  • #2
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    621
    Thanks
    0
    Thanked 6 Times in 6 Posts
    we could do it, but we'd need information on how your blog is setup. Do you use a service? Is it written yet? Is it a custom one you wrote? downloaded?


    -Celt

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I coded mostly everything. It's my own site, no services. My host gives me basicly any extension I want so that's not really an issue.
    The basic set up is
    Code:
    <span class="entry">
              <h3>
              October 2<sup>nd</sup>
              </h3>
              Content
    </span>
    Adding an id to the span would be easy.
    Site : http://www.squirrelplayingtag.uni.cc
    The php on the page is the links and the style changer.

  • #4
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    621
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Uhm...hey Squirrel...lol

    in the process of creating this, I'm going to end up with a complete blogging system. It should be modular enough to work with what you've got, though.

    When I'm done, you'll need to create the comments table in your database and configure the script. Access should be fairly easy:

    Example Link to add comment:
    Code:
    <a href="blog.php?id=127">Add Comment</a> | <?php print $entry->num_comments; ?> Comments
    i'm almost done with just the comments part. I'll let u know when I'm finished.

  • #5
    Regular Coder
    Join Date
    Jan 2004
    Location
    Maryland
    Posts
    468
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow thanks. I thought you had one and could just make a few changes, I didn't mean for you to make one. But if your going to thats awsome. Thank you so much.

  • #6
    Regular Coder
    Join Date
    May 2002
    Location
    Virginia, USA
    Posts
    621
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Ok. I figured I'd give you first crack at this code.

    First, a few notes:

    I haven't documented the class yet.
    There are notes at the top of "Edit.class"....this is my to-do list...and it is growing. Such as:

    • The code needs a a *lot* of cleanup. Some of the functions need to be better defined with return values.
    • I have an init function...I need a destructor for the object
    • PHP 5 support (didn't know what u had, so I worked with PHP4 compat)
    • Several functions contain lots of similar code. This is usually an indication of poor design, and in this case, it is. I need probably need to rename the project to "Blog.class" with "entry.class" and "comments.class" as children and/or seperate classes.
    • documentation?
    • documentation?
    • documentation?
    • A more concise style/template system
    • an additional template/style for the comments/single-entry display
    • It is never a good idea to allow public access of variables the way the script does. It should be rewritten to use a $instance->get() function
    • several other little things, that I need to fix


    General Directions:
    • db_sql contains the sql to setup the database & 2 tables. Create a database called db_blog (or change the one in the file to match an existing one), and import the file.
    • db_info.php contains database connection options. These are in php to help prevent unauthorized viewing. You'll need to edit this.
    • blog_config.ini is the beginning of some of the blog specification options. This isn't documented yet, but everything uses a template of some sort (the [files] section)
    • blog.php is the starting point. You'd go to http://server/directory/blog.php to get things started, if using a full system
    • All other files not (except Edit.class) can be edited and changed. These were created to give you an idea as to what the links should look like.
    • If you're having problems integrating with your existing system, you'll probably need to edit the SQL statements in places like the display_comments function in Edit.class.



    Note...this system doesn't have any way to actually add blog entries. lol. I added them manually through mysql_front. There is also no validity checking, and it's lacking in just so many areas I'd rather not go into it.

    But there you have it. I hope to add an admin panel, user authentication, and an install script for the entire blog. Anyways...just figured I'd give you something to maybe get started with.

    -Celt

    ps. it's attached in the zip file, in case you missed it.

    pps. use at own risk :P

    ppps. consider this version 0.4
    Attached Files Attached Files


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •