PDA

View Full Version : $theard_title in posts/bbcode


Ghostt
10-25-2009, 07:02 PM
how do I get the Topic -title shown in the post (and in the bbcode)? "$title" or "$theard_title" does not work.


in phpbb3 it was solved with a simple code snippet:


open viewtopic.php
find
'MESSAGE' => $message,

replace with
'MESSAGE' => str_replace('{title}', $topic_data['topic_title'], $message),
For every time someone writes {title} is replaced by the title of the topic.

Lynne
10-26-2009, 03:09 AM
Show it in what bbcode? You could write a plugin to do a str_replace, I suppose. I'm really not sure what to suggest since I don't have a clear picture of what you are wanting to do.

Ghostt
10-26-2009, 04:17 PM
Ok i have to tell you what i want to do with it:
For example if i want to search for the topic title in youtube:
http://www.youtube.com/results?search_type=&search_query=$theard_title+trailer&gl=DE

the link would be in a bbcode ...

the "$theard_title" for example would be the parse for the Topic title ..... but isnt working

--------------- Added 1256587704 at 1256587704 ---------------

do you understand what i mean now?

--------------- Added 1256598545 at 1256598545 ---------------

no ideas?

Ghostt
10-30-2009, 08:30 AM
help here pls!

--------------- Added 1256919424 at 1256919424 ---------------

no coders here?

RenatoMN
10-31-2009, 10:36 PM
Try it:

AdminCP > Plugins > Add a Plugin

Product: vBulletin
Hook: postbit_display_complete
Title: Replace thread title
Execution order: 5
$post[message] = str_ireplace("{title}","$foruminfo[title]",$post[message]);
Plugin is active: Yes //do not forget this :)

(you may see a line break here, but it's all a single line)

note: str_ireplace (case insensitive) is a bit more intensive than str_replace.
Use str_replace if you prefer (your users will forced to use it in lowecase).

Ghostt
11-01-2009, 01:08 PM
i called it with {title} right?
but it shows nothing. ... not working for me :/ do youve tested it=?
Try it:

AdminCP > Plugins > Add a Plugin

Product: vBulletin
Hook: postbit_display_complete
Title: Replace thread title
Execution order: 5
$post[message] = str_ireplace("{title}","$foruminfo[title]",$post[message]);
Plugin is active: Yes //do not forget this :)

(you may see a line break here, but it's all a single line)

note: str_ireplace (case insensitive) is a bit more intensive than str_replace.
Use str_replace if you prefer (your users will forced to use it in lowecase).

--------------- Added 1257174418 at 1257174418 ---------------

no help?

RenatoMN
11-03-2009, 02:43 AM
Sorry! I tested but I typed it directly here (without copy/pasting) and there's a typo:

It's "$thread[title]"

Final code:

$post[message] = str_ireplace("{title}","$thread[title]",$post[message]);

--

Suggestion for Youtube trailer search:

$post[message] = str_ireplace("{threadtrailer}","<a target=\"_blank\" href=\"http://www.youtube.com/results?search_query=".mb_convert_encoding(str_replace(" ","+","$thread[title]"),"UTF-8")."+Trailer&search_type=&aq=f&oq=\">".$vbphrase[search]." ".$thread[title]." Trailer @ YouTube</a>",$post[message]);


In a thread titled "Batman Begins" will convert {threadtrailer} to: Search Batman Begins Trailer @ YouTube (http://www.youtube.com/results?search_query=Batman+Begins+Trailer&search_type=&aq=f&oq=)

Or a simplified:

$post[message] = str_ireplace("{threadtrailer}","<a target=\"_blank\" href=\"http://www.youtube.com/results?search_query=".mb_convert_encoding(str_replace(" ","+","$thread[title]"),"UTF-8")."+Trailer&search_type=&aq=f&oq=\">".$vbphrase[search]." Trailer @ YouTube</a>",$post[message]);

In a thread titled "Batman Begins" will convert {threadtrailer} to: Search Trailer @ YouTube (http://www.youtube.com/results?search_query=Batman+Begins+Trailer&search_type=&aq=f&oq=)
(no thread name in the visible link, only in URL)

Note: if you edit the code, do not remove mb_converting_encoding. It is necessary because YouTube use UTF-8, so if your forums use ISO-8559-1, you will ever see "no results" when you click the link in a thread with ANY accentuated character.