|
|
| Author |
Message |
roppie
New User
Joined: 28 Feb 2006
Posts: 6
Location: Netherlands
|
Posted: August 17th 2010, 12:59 pm Post subject: BBCode for postid |
|
|
Hello,
I've set up an mobile version of my website in which i'm using different .php-files for mobile and desktop (e.g. mobviewtopic.php for mobile). In some of my topics are links to other topics. Now I'm looking for a bbcode which gives me the possibility to just put the postid number, so it refers to the mobile pages on the mobile version en to the desktoppages on the desktopversion.
Something like: [post=5736]example text[/post]
I'm looking for it already a couple of days, but still haven't found it. I hope you can help me with it.
Thanks in advance. |
|
| Back to top |
|
 |
Patrick
Admin/Webmaster

Joined: 11 May 2001
Posts: 17279
Location: Harbinger, NC, U.S.A.
|
|
| Back to top |
|
 |
roppie
New User
Joined: 28 Feb 2006
Posts: 6
Location: Netherlands
|
Posted: August 22nd 2010, 1:28 pm Post subject: |
|
|
This is what i set up my own, but it doesn't work.
includes/bbcode.php
| Code:
|
$bbcode_tpl['post'] = str_replace('{URL}', '\\1', $bbcode_tpl['post']);
$bbcode_tpl['post'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['post1']);
|
| Code:
|
// [post=postid]Post ID[/post] code..
$patterns[] = "#\[post=(0-9)\](.*?)\[/post\]#is";
$replacements[] = $bbcode_tpl['post1'];
|
templates/.../bbcode.tpl
| Code:
|
|
<!-- BEGIN post --><a href="http://www.---.nl/phpbb/viewtopic.php?p={URL}#{URL}" class="postlink">{DESCRIPTION}</a><!-- END post -->
|
I don't need the code in the faq, or posting.tpl. I just want it to work in posts. |
|
| Back to top |
|
 |
roppie
New User
Joined: 28 Feb 2006
Posts: 6
Location: Netherlands
|
Posted: August 31st 2010, 7:20 am Post subject: |
|
|
I finally fixed it myself. This is the right code, in case someone else likes this mod.
includes/bbcode.php
| Code:
|
$bbcode_tpl['post1'] = str_replace('{URL}', 'viewtopic.php?p=\\1#\\1', $bbcode_tpl['post']);
$bbcode_tpl['post1'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['post1']);
|
| Code:
|
// [post=postid]Post ID[/post] code..
$patterns[] = "#\[post=([0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9]?[0-9])\](.*?)\[/post\]#is";
$replacements[] = $bbcode_tpl['post1'];
|
templates/.../bbcode.tpl
| Code:
|
|
<!-- BEGIN post --><a href="{URL}" class="postlink">{DESCRIPTION}</a><!-- END post -->
|
|
|
| Back to top |
|
 |
Patrick
Admin/Webmaster

Joined: 11 May 2001
Posts: 17279
Location: Harbinger, NC, U.S.A.
|
|
| Back to top |
|
 |
roppie
New User
Joined: 28 Feb 2006
Posts: 6
Location: Netherlands
|
Posted: September 13th 2010, 1:39 am Post subject: |
|
|
One little update on the code:
| Code:
|
$bbcode_tpl['post1'] = str_replace('{URL}', 'viewtopic.php?p=\\1#\\1', $bbcode_tpl['post']);
$bbcode_tpl['post1'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['post1']);
|
replace by
| Code:
|
$bbcode_tpl['post1'] = str_replace('{URL}', '#\\1', $bbcode_tpl['post']);
$bbcode_tpl['post1'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['post1']);
|
This makes it faster, because it uses #postid instead of the full link, but it works only if the post is on the same page as the link.
Besides if someone uses this update, you might need an [topic]-code as well, to link to other topics, because topic-id's work with "t=" instead of "p=". |
|
| Back to top |
|
 |
Patrick
Admin/Webmaster

Joined: 11 May 2001
Posts: 17279
Location: Harbinger, NC, U.S.A.
|
|
| Back to top |
|
 |
|