vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Need help with preg_match plugin (https://vborg.vbsupport.ru/showthread.php?t=325407)

unitedpunjab 07-18-2017 02:40 PM

Need help with preg_match plugin
 
I have tried various $post variables and hook locations.
Couldn't get it working.
Kindly assist if it is doable.

PHP Code:

$fost $post['postparsed'];
if (
preg_match'/embed([^"]+)'$fost $match ))
        {
        
$test $match[1];
        } 

then echo $test in headinclude template.

Dave 07-18-2017 02:43 PM

You might want to tell us what you want to accomplish first. :)

unitedpunjab 07-18-2017 03:13 PM

I want to get the youtube video id from thread / post and use it for meta og:image. in headinclude. or showthread.

Got it working for https://vborg.vbsupport.ru/showthrea...hreadid=323668

with preg_match in php script (amp.php).

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

This is the code I am trying to plugin-fy.

PHP Code:

        $post['message'] = $bbcode_parser->parse($post['pagetext'], 'nonforum'false); 

        if (
preg_match'/embed([^"]+)/'$post['message'] , $match ))
        {
        
$imgstr 'https://img.youtube.com/vi/'.$match[1].'/0.jpg';
        } 


unitedpunjab 07-20-2017 10:33 AM

This works in "postbit_display_start" hook, "$test" returns da value I want but only in "postbit" template.

How do i get the value in headinclude or showthread template ?

PHP Code:

$fost $this->post['pagetext'];
if (
preg_match'/youtube.com\/watch\?v=([^"]+)\[/'$fost $match ))
        {
        
$test $match[1];
        } 

Edit: this worked

Code:

$find = '$YTIMG';
$vbulletin->templatecache['SHOWTHREAD'] = str_replace($find, $ytimg, $vbulletin->templatecache['SHOWTHREAD']);



All times are GMT. The time now is 09:05 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01026 seconds
  • Memory Usage 1,727KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete