Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-14-2014, 07:43 PM
XiTCLUB XiTCLUB is offline
 
Join Date: Jan 2010
Location: Lahore, Pakistan
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Using Dailymotion Api in BB Code Template

Hi,
I wanted to use HTML5 schema in my BB code templates and wanted to fetch video data via dailymotion API and for that i have to create and echo variables inside template

The code i am using is
PHP Code:
<?php
$id
={vb:raw code};
$thumbnail_medium_url='https://api.dailymotion.com/video/'.$id.'?fields=thumbnail_720_url';
$json_thumbnail file_get_contents($thumbnail_720_url);
$get_thumbnail json_decode($json_thumbnailTRUE);
$thumb=$get_thumbnail['thumbnail_720_url'];
?>
and i am echoing it like this
PHP Code:
<?php echo $thumb ?>
but this is not working like it should and just printing whole statement as it is
Reply With Quote
  #2  
Old 04-14-2014, 09:25 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can't use PHP in the bbcode templates, or any templates for that matter.
Reply With Quote
  #3  
Old 04-14-2014, 09:52 PM
XiTCLUB XiTCLUB is offline
 
Join Date: Jan 2010
Location: Lahore, Pakistan
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery View Post
You can't use PHP in the bbcode templates, or any templates for that matter.
Yeah i see and i figure out things with Tutorials and template system and i came too close.
I created a Plugin with this code
PHP Code:
function video_api_thumb($vid){
$id $vid;
$thumbnail_720_url='https://api.dailymotion.com/video/'.$id.'?fields=thumbnail_720_url';
$json_thumbnail file_get_contents($thumbnail_720_url);
$get_thumbnail json_decode($json_thumbnailTRUE);
$thumb=$get_thumbnail['thumbnail_720_url'];
}
$thumb_url video_api_thumb('x17r8h7');
$templater vB_Template::create('dailymotion_video_api');
$templater->render();
vB_Template::preRegister('bbcode_video',array('video_thumb_url' => $thumb_url)); 
and used this in my bbcode_video
PHP Code:
Thumbnail : {vb:raw video_thumb_url
Now its printing Thumbnail URL in my thread view but i want to use dynamic video id instead of hard coded one i function ($thumb_url = video_api_thumb('x17r8h7');). how can i pass a video id to that plugin function so it will return fresh thumbnail ??
Reply With Quote
  #4  
Old 04-14-2014, 11:38 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Take a look at the video bbcode related stuff.
Reply With Quote
  #5  
Old 04-15-2014, 09:51 AM
XiTCLUB XiTCLUB is offline
 
Join Date: Jan 2010
Location: Lahore, Pakistan
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Zachery View Post
Take a look at the video bbcode related stuff.
There is something like this {vb:raw code} in "bbcode_video" in templates. now how can i send this {vb:raw code} to plugin ??
Reply With Quote
  #6  
Old 04-25-2014, 07:57 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You can remove these two lines from your code:
Code:
$templater = vB_Template::create('dailymotion_video_api');
$templater->render();
because they aren't doing anything ($templater->render() returns a string).

I understand that you want the video id to be a parameter, but I don't understand where you want to enter it.

Edit: Maybe you want to provide the code as part of the bbocde? Which hook location are you using for your plugin?
Reply With Quote
  #7  
Old 04-25-2014, 08:30 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

By the way, have you looked at this mod: https://vborg.vbsupport.ru/showthread.php?t=230707 ? Maybe it already does what you want.

And I noticed that there are a couple older mods below in the "Similar Threads" section below. They are for older versions, but they still might work with vb4, or at least give you an idea of how to do it.

Edit: Oh, well, I guess you're trying to use the api to get the thumbnail and not just embed the video, so maybe those don't help.
Reply With Quote
  #8  
Old 04-25-2014, 08:36 PM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Also, if you just want to use dailymotion, you can update the bbcode_video.xml file, no need for a lot of complicated nonsense.
Reply With Quote
  #9  
Old 04-26-2014, 05:20 AM
XiTCLUB XiTCLUB is offline
 
Join Date: Jan 2010
Location: Lahore, Pakistan
Posts: 304
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
You can remove these two lines from your code:
Code:
$templater = vB_Template::create('dailymotion_video_api');
$templater->render();
because they aren't doing anything ($templater->render() returns a string).

I understand that you want the video id to be a parameter, but I don't understand where you want to enter it.

Edit: Maybe you want to provide the code as part of the bbocde? Which hook location are you using for your plugin?
Okay i have removed those lines and i am using hook location "global_start"
i want to get video id from thread where video is embedded and parse that id to my plugin function so i can get video_tubmnail, title, length and other stuff from dailymotion

--------------- Added [DATE]1398493348[/DATE] at [TIME]1398493348[/TIME] ---------------

Quote:
Originally Posted by Zachery View Post
Also, if you just want to use dailymotion, you can update the bbcode_video.xml file, no need for a lot of complicated nonsense.
I can see that you are not getting what i wanted to do. i am not stupid enough to get stuck on just embedding videos.
Reply With Quote
  #10  
Old 04-26-2014, 06:50 AM
Zachery's Avatar
Zachery Zachery is offline
 
Join Date: Jul 2002
Location: Ontario, Canada
Posts: 11,440
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Please enlighten me, why can't you just update the video bbcode template?
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:33 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04480 seconds
  • Memory Usage 2,269KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (4)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete