Need to change phpbb3 bbcode to html.. not working please help!

  • barry
  • Graduate
  • Graduate
  • User avatar
  • Posts: 115
  • Loc: scotland

Post 3+ Months Ago

Hi all. I am making a custom page for the home page of my website but I am looking to add the firts post from the news section of the forum as the text for the home page of the website.

I have it working fine but the only trouble i have is showing images dosnt work. I am using PHPBB3 and it includes the user ID next to the bbcode tags and im struggling to remove it. Here is what I have (and its not working)

The image BBCODE comes from the database like this

Code: [ Select ]
[img:432154]http://www.IMAGE URL HERE.jpg[/img]


Ok is this was just like

Code: [ Select ]
[img] URL HERE[/img]


that would be fine I would just use the

Code: [ Select ]

$r = str_replace("[img]","<img src='",$r);
$r = str_replace("[/img]","'>",$r);
  1. $r = str_replace("[img]","<img src='",$r);
  2. $r = str_replace("[/img]","'>",$r);



BUT I need to replace the user id code that is next to the [img] tag which appears like this [img:423433]

I have tried this too

Code: [ Select ]

$r = preg_replace('/\[img(.*)\]/','TEST',$r);
  1. $r = preg_replace('/\[img(.*)\]/','TEST',$r);


I have simply tried to replace the start of the opening image tage to the first ] with the word test but it dosnt work. It actaully replaces the whole [img:123123] to the end [/img] and the url in between with the word TEST.

Please help any one.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

With phpBB when you use any bbcode, it also stores a bbcode_uid into your database. The bbcode_uid are those weird numbers that you see in your bbcode. So for example here:

Quote:
[img:432154]http://www.IMAGE URL HERE.jpg[/img]


Those bold numbers are the bbcode uid which you could extract from the database. So let say you do also extract the bbcode_uid from the database too, it would be very easy then to do what you want. Lets say you store the bbcode_uid as a variable like so:

PHP Code: [ Select ]
$data['bbcode_uid']


You could then do this:

PHP Code: [ Select ]
$r = str_replace("[img:" . $data['bbcode_uid'] . "]","<img src='",$r);
  • barry
  • Graduate
  • Graduate
  • User avatar
  • Posts: 115
  • Loc: scotland

Post 3+ Months Ago

Thanks m8.. I worked it out eventually by making a full new template for a basic page and not having to use the replace all all.. now all the bbcode is working perfectly and I have also learned how to correctly make a custom phpbb page (which you can see here www.barry2.co.uk )

thanks for the help though ;)

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 76 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.