Serifaz Posted February 8, 2013 Share Posted February 8, 2013 Hello I have been working on developing a custom forum software for personal use. I have everything done accept for the youtube integratio the align and link features in the post. As of right now Im more concerned with the youtube integration. I am currently using js to add the button and tags to the post and php to implement what the tags do. Currently the button is fine it posts the youtube tags which are [vid][/vid] I am just having trouble figuring out how to assing a variable so that a user can input the video id. I am trying to replace {PARAM} with the video id. here is what I have on the php file. ; $r = str_replace("[vid]","<object width='425' height='344'><param name='movie' value='http://www.youtube.com/v/{PARAM}'></param><param name='allowFullScreen' value='true'></param><param name='allowscriptaccess' value='always'></param><embed src='http://www.youtube.com/v/{PARAM}' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='425' height='344'></embed></object>",$r); $r = str_replace("[/vid]","",$r); $r = str_replace("{PARAM}", "KcuJAe3TrQw",$r); I have put a video id of KcuJAe3TrQw in quotes to see if the youtube will get put in if I just use the tags and it indeed does. What I want to do is replace the id with a variable that I can let the user asign the id to... How would I do this or something relevant that would work. Also if you have any spare time I would love to know what I am doing wrong with the align $r = str_replace(" [center]","align=center",$r); $r = str_replace("[/center] ","'>",$r); Thanx for looking at my post and I hope you can help me Quote Link to comment https://forums.phpfreaks.com/topic/274186-custom-forum-youtube-integraton/ Share on other sites More sharing options...
cyberRobot Posted February 8, 2013 Share Posted February 8, 2013 The ID could be entered into the [vid] tag...similar to the BBCode for links (http://www.bbcode.org/examples/?id=9). [vid=KcuJAe3TrQw][/vid] The ID could be pulled from the tag and used for the string replace function. As for your other question, shouldn't the open center tag ( ) be replaced with an open HTML tag? The close tag would be replaced with the corresponding HTML close tag. For example <?php $r = "[center]Center this[/center] "; $r = str_replace(" [center]","<div align='center'>",$r); $r = str_replace("[/center] ","</div>",$r); print $r; ?> Quote Link to comment https://forums.phpfreaks.com/topic/274186-custom-forum-youtube-integraton/#findComment-1410995 Share on other sites More sharing options...
Serifaz Posted February 8, 2013 Author Share Posted February 8, 2013 Hey sorry I am having trouble understanding. How exactly do I use the tags to let the user specify the youtube id. I get that I can make the tags work like [vid=KcuJAe3TrQw][/vid] but how do I make it so that in the code I gave the vid tag will not need to be set to just one video. Sorry Im not very experienced with bbcode. can you give me an example of how I would use the {PARAM} to let the user assign what is in that part of the url? Quote Link to comment https://forums.phpfreaks.com/topic/274186-custom-forum-youtube-integraton/#findComment-1411067 Share on other sites More sharing options...
cyberRobot Posted February 8, 2013 Share Posted February 8, 2013 Too be honest, I don't really work with BBCode beyond using it in message boards like this one. However, maybe the BBCode functions in PHP will help: http://php.net/manual/en/book.bbcode.php Quote Link to comment https://forums.phpfreaks.com/topic/274186-custom-forum-youtube-integraton/#findComment-1411081 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.