On these pages are my WordPress plugins, the odd article and my Support Forum.

For my random rantings on everything else please visit my blog at Yellow Swordfish

WP Plugins


Articles

If you find any of my plugins useful, please comsider a donation towards my running costs.

Thank you

Current User: Guest
Please consider registering

 
Search Forums:


 




permal link problem:blog post auto create forum topic

UserPost

7:01 pm
6 Apr 2008


sbtalk

Member

sbtalk

posts 5

 
1

I am chinese bloger. (http://www.sbtalk.com.cn/sf-forum/)


I installed spf 3.0.3(successfully converted from wp-forum which has security issue reported recent), when trid to create link from blog post to forum topic, I got problem: the permalink for forum thread is missed. I found forum post permal-link is built from blog post's title which in my bloger is all chinese character.


for 2 examples(maybe, you cant view my site because of foreign language, so just describe it):

1. I wrote a blog post in title with some english character like : xxx- wp-forum xxx sfp xxxx [xxxx is chinese character],

after click “create link” then publish, I found there is a post in forum with permal link /sf-forum/forum-10/page-1/wp-forum-sfp, all chinese character missed, anyway, I can click in this topic.


2. I wrote a blog post in title with all chinese character like : xxxxxxx

the post title in forum can be displayed, but when I click it, it is still in forum post lists page, and the permal-link, when I mouse over, is /sf-forum/forum-10/page-1


actually, in the 2nd sample, I use english slug for blog post.


my questions is , can I use blog post id or blog post slug as forum post permal-link?


btw:when convert from wp-forum, the conversion plugin stopped when //move on topic , the function mpc_wrtie_topic used var $targettopicslug which is converted from wp-forum $topicname,acutally it is toally chinese character in my site. I re-write the function to used $topic-id which is unique[see demo screen below, some chinese desc, but may not lead mis-understanding]. I think my above question was casued by same reason, right?

then



7:14 pm
6 Apr 2008


Yellow Swordfish

Admin

Peterborough, England

posts 5015

 
2

I'm not sure I followed all this. I can say that the creation of the forum and topic 'slugs' has changed in 3.0.3 in that if it can not create the slug (because of characters) and it returns empty then the forum/topic id is used instead prefixed with the type (so 'forum-12', 'topic-102' etc).


Are you saying this did not happen?

7:30 pm
6 Apr 2008


sbtalk

Member

sbtalk

posts 5

 
3

it did not happen in form of forum/topic .


I just created a blog post right now, http://www.sbtalk.com.cn/2008/04/07/spftestpage.html

you can see, the blog post slug I used is english “spftestpage”

but when you click/mouse over the link inside the post “Join the forum discussion on this post“, it jumps to forum post lists,


my forum post permal-link is like /fourm-id(or name)/topic-id/page-id


but when post is auto-created by blog, the permal-link is /fourm-id(or name)/page-id, no topic-id there.

12:14 pm
7 Apr 2008


Yellow Swordfish

Admin

Peterborough, England

posts 5015

 
4

Sorry - I have not been ignoring this but I have been running some tests.

I wil ltry and get to the bottom of this - there is obviously a problem somewhere…Apologies for that.

5:37 pm
7 Apr 2008


sbtalk

Member

sbtalk

posts 5

 
5

thanks so much.

before next update, actually, I was trying to track code. now I temporarily resolved problem. I list issues I found for your reference here. the main problem here are 2 files: sf-links.php and sf-support.php


in sf-links.php

line#104:$content = $wpdb->get_row(”SELECT post_content, post_title, post_author, post_status FROM “.$wpdb->prefix.”posts WHERE ID = “.$postid.”;”);

line#112:

$post_title = $wpdb->escape($content->post_title);

line#114-118:

$slug = sf_create_topic_slug($post_title);
$sql = “INSERT INTO “.SFTOPICS.” (topic_name, topic_slug, topic_date, forum_id, user_id, blog_post_id) VALUES ('”.$post_title.”', '”.$slug.”', now(), “.$_POST['sfforum'].”, “.$content->post_author.”, “.$postid.”);”;
$wpdb->query($sql);

check above code, it tried to retrieve post_title from wpdb, convert to topic slug. then insert to table “sfposts”.

it caused problem if blog title contrains all chinese character. after check wordpress db, I found it uses post_name for slug. so I just changed code as below:

line#104:(select one more field 'post_name' from wpdb)$content = $wpdb->get_row(”SELECT
post_content, post_title, post_author, post_status, post_name FROM
“.$wpdb->prefix.”posts WHERE ID = “.$postid.”;”);

line#112:(not touch)

$post_title = $wpdb->escape($content->post_title);

line#114-118:(use blog-post slug to create forum-topic slug)

$slug = sf_create_topic_slug($content->post_name);
$sql = “INSERT INTO “.SFTOPICS.” (topic_name, topic_slug, topic_date,
forum_id, user_id, blog_post_id) VALUES ('”.$post_title.”',
'”.$slug.”', now(), “.$_POST['sfforum'].”,
“.$content->post_author.”, “.$postid.”);”;
$wpdb->query($sql);

—————————————–

the next issue is function 'sf_create_topic_slug' in sf-support.php.

suppose, even the slug name was converted from chinese character above and return empty str,

sf_create_topic_slug should deal with it. but in current version, it does not.

line#1165-1166:

$title = sf_create_slug($title);
if(empty($title)) return '';

in above code, if $title is empty then return empty str? I changed code for temp solution.

line#1165-1166:

$title = sf_create_slug($title);
if(empty($title)) $title = 'unknow_topic';

it assigned $title as 'unknow_topic' and not return, going next code segment to attach incremental surffix, like unknow_topic-1, unknow_topic-2 (in case already had 'unknow_topic' there)


hope in next update. it can use topic-id instead.


the other minor issue:

1. while edit blog-post, the “create link” select list can not display correct forum name. checked sf-links.php, found code like,

line#34

$forumid = $islink->meta_value;

it can not get correct forumid on my php5, I changed it as

line#34

$keys = explode('@', $islink->meta_value);
$forumid = $keys[0];

it works.


2. in sf-links.php

line#14:

add_action('save_post', 'sf_save_blog_link');

actually, it does nothing, especially when I tried to link my old blog post to forum. so I just change it as

line#14:

add_action('save_post', 'sf_publish_blog_link');

use publish action hook instead


hope above info would be helpful.Smile

6:25 pm
7 Apr 2008


Yellow Swordfish

Admin

Peterborough, England

posts 5015

 
6

I fixed this today and was goign to offer you the code but you seem to have nailed it. More or less what I found.

Thanks for the detail



Reply to Topic: permal link problem:blog post auto create forum topic

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 11 + 11        (Required)

Topic Reply:


 
 

About the Stuff at Yellow Swordfish forum

Currently Online:

9 Guests

Maximum Online: 71

Forums:

Groups: 3

Forums: 16

Topics: 1941

Posts: 13162

Members:

There are 916 members

There are 796 guests


Yellow Swordfish has made 5015 posts

Top Posters:

Mr Papa - 1437

-Radio- - 518

ovizii - 106

jfv - 82

RoseCitySister - 68

Administrator: Yellow Swordfish | Moderators: Yellow Swordfish, Mr Papa, -Radio-


© Simple:Press Forum - Version 3.1.4 (Build 357)