Forum Replies Created
-
In reply to: Having trouble integrating WP functions
Could you paste the web server’s error log?
In reply to: subforums and markup@itissue: Didn’t fel64’s method work?
In reply to: Excerptsfel64 is right. So I made a change.
<?php
// from wp_trim_excerpt() in WordPress 2.3.1 formatting.php, just removed few lines
function make_excerpt($text) { // Fakes an excerpt if needed
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = 55;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
return $text;
}
if ( $topics ) :
$last_post_ids = array();
foreach ( $topics as $topic )
$last_post_ids[] = $topic->topic_last_post_id;
global $bbdb;
$post_ids = $bbdb->get_col( "SELECT post_id, post_text FROM $bbdb->posts WHERE post_id IN (" . implode(',', $last_post_ids) . ")");
$post_texts = $bbdb->get_col( null, 1 );
$post_excerpts = array();
foreach($post_ids as $idx => $post_id)
$post_excerpts[$post_id] = make_excerpt( $post_texts[$idx] );
endif;
?>
<?php if ( $topics ) : foreach ( $topics as $topic ) : ?>
<tr<?php topic_class(); ?>>
<td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a>
<?php echo $post_excerpts[$topic->topic_last_post_id]; ?>
</td>
<td class="num"><?php topic_posts(); ?></td>
<td class="num"><?php topic_last_poster(); ?></td>
<td class="num"><small><?php topic_time(); ?></small></td>
</tr>
<?php endforeach; endif; // $topics ?>On my test forum, 15 posts, without excerpts takes .119 sec, with excerpts takes .127 sec. Previous code takes .140 sec.
In reply to: ExcerptsReplace the similar part with it in front-page.php (Kakumei):
<?php if ( $topics ) : foreach ( $topics as $topic ) : ?>
<tr<?php topic_class(); ?>>
<td><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a>
<?php
// from wp_trim_excerpt() in WordPress 2.3.1 formatting.php, just removed few lines
function make_excerpt($text) { // Fakes an excerpt if needed
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text);
$excerpt_length = 55;
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
}
return $text;
}
echo make_excerpt( get_post_text( $topic->topic_last_post_id ) );
?>
</td>
<td class="num"><?php topic_posts(); ?></td>
<td class="num"><?php topic_last_poster(); ?></td>
<td class="num"><small><?php topic_time(); ?></small></td>
</tr>
<?php endforeach; endif; // $topics ?>It generates an excerpt of latest reply of topic.
In reply to: database MINOR issueHere is my explanation:
The question is should we reuse deleted ID?
1. Says we have ID from 1 to 10. ID 5 is just deleted and a new user just registered. How does the program know which ID should be assigned to this new user? If this program reuse ID, then it have to go through the entire data, just for find out which ID is available. Or add another table for storing those deleted IDs? Reusing ID makes performance issue.
2. If this new users is assigned ID 5, then the admin suddenly find out he deleted wrong user, that should be another user. And if this program can partially restore data, can this program just do that? It can’t. ID 5 has been assigned to a new user, if you want to restore that deleted user, you may need to assign a new ID to that deleted user.
3. Now, think about a products database. You deleted a product, and inserted another one with same ID (assuming 5). If there is another program can order products using IDs only, it says it wants ID 5. But it actually meant old ID 5, not new ID 5. If you don’t reuse ID, then the transaction can’t be done.
In reply to: Would copying the theme of bbpress.org be illegal?I think all bbPress themes are protected by GPL since they must call bbPress functions.
By GPL, you can modify, redistribute, or even almost change nothing to re-release as long as you don’t claim yourself is the only one copyright holder if you are not. Just don’t replace “Copyright YEAR HOLDERS”, but append new one with your name. Moreover, If someone asks for the source, you have no reasons to refuse the request.
PS. I am not sure I am totally correct.
You need this https://trac.bbpress.org/attachment/ticket/745/745c.diff
and don’t use unix socket.
If you have to use unix socket, read https://bbpress.org/forums/topic/cannot-select-db-error?replies=11#post-12434
In reply to: ExcerptsIf you just call the template functions of WordPress, that won’t work. I meant get the part you need. (sorry for misleading)
PS. If you still can’t get it work, please paste your code and error message, if any.
In reply to: ExcerptsI think you can just copy/use WordPress’ excerpt generating function, just a thought but I know that will work.
In reply to: Replace word in PostI just finished uploading talkPress 002: A Simple bbPress Plugin – Bad Words Filter. You can watch this here.
The code mentioned in video is:
<?php
/*
Plugin Name: Bad Words Filter
Plugin URI: http://www.livibetter.com/
Description: Removing bad words from post content
Author: Yu-Jie Lin
Author URI: http://www.livibetter.com/
Version: 0.1
*/
function BadWordsFilter($post_text) {
// $post_text = str_ireplace('bad', '*****', $post_text);
$bad_words = array('bad', 'topic', 'cialis');
foreach($bad_words as $bad)
// $post_text = str_ireplace($bad, '*****', $post_text);
$post_text = preg_replace("/\b$bad\b/i", '*****', $post_text);
return $post_text;
}
add_filter('post_text', 'BadWordsFilter');
?>In reply to: Replace word in PostYou also need http://tw2.php.net/str_replace
I think it’s better to write a plugin (using a filter) for this task, instead of modifying template. (ya… this would be a good example to be “How to write a plugin” on my podcast show)
In reply to: Limiting PaginationCheck out your
config.php
again.In reply to: Anyone Using Feeling Gray Theme?That function isn’t in bbPress core. You may need to ask template’s author about that function. But I think just removing it is ok.
In reply to: Anyone Using Feeling Gray Theme?Maybe that is about this plugin: Support Forum?
In reply to: A video about integrating bbPress into WordPressThat’s a good topic, however I think PHP 101 should be come next?
PS. I am re-uploading .flv and .mp4.
In reply to: Add nofollow to linksHere it is:
<?php
/*
Plugin Name: My own tweak for my forums
Plugin URI: https://bbpress.org/
Description: Fine tuning codes for my forum
Author: Your name
Author URI: http://www.myforum.com/
Version: 0.1
*/
add_filter('post_author_link', 'bb_rel_nofollow');
?>Basically, you can put many fine tuning codes within one PHP files, and this file is for your forum only. Remember to activate this plugin.
In reply to: Add nofollow to linksYou can simply add that line into
bb-includes/default-filters.php
or
create your own plugin file with that line.
In reply to: Server requirements?Read requirements.
In reply to: Next page not workingAbout
MultiViews
, I recently re-read FAQ. There is a note for not working MultiViews.3. Try it out. If it doesn’t work, your web server does not support MultiViews. Instead, you’ll need to remove that line from your .htaccess file and replace it with the several lines bbPress generates for you when you browse to your bbPress installation’s /bb-admin/rewrite-rules.php.
Maybe you can try it and let us know if that works?
In reply to: Cannot select DB error!Are you using 0.8.3?
Try to patch with https://trac.bbpress.org/ticket/757
or
modify https://trac.bbpress.org/browser/trunk/bb-includes/db-mysqli.php#L56
to be
$this->$dbhname = @mysqli_connect( $server->host, $server->user, $server->pass, null, null, $server->port );
In reply to: DocumentationThe best way to work with bbPress is reading the source, currently. Unfortunately, not everyone can code.
Btw, your Programming page of blog has an error.
In reply to: Delete Forum with SubforumI tested on my test forum (no plugins activated), that didn’t happen. The subforums of deleted forum were promoted one level.
In reply to: Registration Email Not Being Sent – new issue14 HOURS??? You will lost many users!
In reply to: Front page stickies on forum pages?No ideas. But it has something to do with
bb_index.php_pre_db
( https://trac.bbpress.org/browser/trunk/index.php ) orbb_forum.php_pre_db
actions. So I just left it unchanged.In reply to: Front page stickies on forum pages?This should work:
<?php
if ( !$bb_db_override ) :
$super_stickies = get_sticky_topics();
endif;
?>
<?php if ( $super_stickies ) : foreach ( $super_stickies as $topic ) : ?>
<tr<?php topic_class(); ?>>
<td><?php bb_topic_labels(); ?> <big><a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></big></td>
<td class="num"><?php topic_posts(); ?></td>
<td class="num"><?php topic_last_poster(); ?></td>
<td class="num"><small><?php topic_time(); ?></small></td>
</tr>
<?php endforeach; endif; // $super_stickies ?>