vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   using PHP in templates (https://vborg.vbsupport.ru/showthread.php?t=327976)

Dr.CustUmz 05-01-2020 01:24 PM

using PHP in templates
 
ok I have been out of the scene for a LONG time, I'm working on a new product, and im just having a huge brain fart.

Im trying to use php in a template I have created what I want to convert to a product in PHP, an example of my source is

PHP Code:

<div class="blah">
<?php 
$i
=0;
foreach(
$result as $row) if ($i 10+1) {
?>
<div class="thing">
  <span class="stuff"><?php echo number_format($row['stuff']);?></span>
</div>
<?php $i +=1;
?>
</div>

I know I cant use php in a template of a product, but what I cant remember is how to create a variable that would equal the php so i can pull that into the template.

Im brain farting so hard.

Global Plugin:
PHP Code:

$var '$i=0; foreach($result as $row) if ($i < 10+1) {';
$var2 'echo number_format($row['stuff']);';
$var3 '$i +=1; }'

Template
HTML Code:

<div class="blah">
$var
<div class="thing">
  <span class="stuff">$var2</span>
</div>
$var3
</div>


Dave 05-01-2020 02:00 PM

That would only work if the variables were evaluated to PHP code, but they are not.
In vBulletin, they would loop in a PHP script and then call the template that would contain:
Code:

<div class="thing">
  <span class="stuff"><?php echo number_format($row['stuff']);?></span>
</div>

To render what is needed.

Dr.CustUmz 05-01-2020 02:14 PM

scratch this, my brain un farted lol. Im going about this wrong, i need to create a plugin with this PHP/HTML in it, and give that the variable, then use that variable in the template..... if that makes sence


All times are GMT. The time now is 03:42 PM.

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.01030 seconds
  • Memory Usage 1,721KB
  • 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
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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