+ Reply to Thread
Results 1 to 4 of 4

Thread: Coding Suggestion

  1. Join Date
    Nov 2005
    Posts
    3

    Coding Suggestion

    First of all, Patiek, this is a great utility and you saved me a ton of time in having to develop something to accomplish this. Thanks!
    The forums are being used as content management for the web site, as they have the login and posting capability already built in, and your work was a perfect match for that.

    I have made some modifications to EP-Dev News to allow the display of only certain topic types. Right now if the user sets the post to an "Announcement", it will show up on the web site - this will be changed to "Web Site" as an additional topic type so it will be more concise and will allow the forums to function as normal.
    The modifications included: a parameter to the functions as well as a checkbox to the generate code page, and of course the additional AND in the SQL WHERE clause.

    The only issue I have come up with is under a no rows found condition, the script is being killed and this causes the rest of the page processing to stop.

    So when I want to display news, but there isn't a qualifying post, the page is stopped right after the message "No posts found in selected forum category.", and the rest of the web page display is abandoned.

    To fix this, I modified the fetch_Posts() rows check to echo the message and return FALSE instead of going to the stop() function:

    Code:
    // error if no posts
    if (!$this->DB->rows())
    {
    	// no row condition is not an error
    	//$this->ERROR->stop("no_posts_found");
    
    	echo "No posts found in selected forum";
    	return FALSE;
    }
    ...
    return $post_count;
    The return $post_count at the end of the function is then also needed so there will be a return value.

    The call in news() is checked for a return and will simply return its own FALSE if needed:
    Code:
    if ( !$this->FORUM[$forums[$i]]->fetch_Posts($number, $ids[$i],...) )
    {
      return FALSE;
    }
    ...
    return count($ALL_POSTS);
    And the initial call in display_News() will simply return if it comes back false:
    Code:
    // grab / process news
    if ( !$this->news($number, $ids,...) )
    {
     return;
    }
    Hope this is of some use to either you or anyone else encountering this.

  2. Join Date
    Aug 2004
    Posts
    781

    Coding Suggestion

    I considered not killing the page execution upon no news, but then I thought that the person should not be using the script in the first place (under its original coding, without your modifications) if there was no news to be displayed


    People have wanted specific topic types implemented for a while now. The reason I haven't been able to get to it is that such a modification would require an update and research into ALL of the forum software that is supported (remember, each forum has its own class that interacts in a modular way with the script).

    Thus, while it is fairly easy for any single user using a single forum to do, it is quite lengthy for me to modify all of the code for all forums (and versions) supported, and proceed to test for every forum.

    There was also a suggestion one time of modifying the script to only display posts from a certain name, but such a task requires modification / testing of all forum software.

    Thanks for your input and feel free to post any modified code if you like for others to use, as you already did.

  3. Join Date
    Nov 2005
    Posts
    1

    Coding Suggestion

    Now that would be something that I really need, would suit perfect... phpBB2 *hint*

  4. Join Date
    Nov 2005
    Posts
    3

    Coding Suggestion

    X-Worm - I sent you an email with those changes. You can email or post here if you have any questions.

+ Reply to Thread

Posting Permissions

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