vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=327981

Foreach in plugin
by Dr.CustUmz
02 May 2020 18:38

So I am trying to use a foreach in my plugin and call it in my template with a variable, since my foreach is open it's breaking my product. How can I go about calling a foreach and include it in my template?


My before product, raw php:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.




so I have my plugin like this (and yes the other variables are defined, this is just where the is)

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

and the template like this

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

and it breaks, the variable
Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

works on its own, but nothing works when i add the portion above it.

Seven Skins 02 May 2020 19:06

I am no expert but …
1 - there is an extra semicolon at line 2 of your php code
2 - PHP variables, I think underscore should be used not dashes

Dave 02 May 2020 20:33

Also PHP doesn't have any type of macro support like that (unlike C++ macro definitions using #define). You can't assign portions of a function to a variable and then execute the function as usual by calling the PHP variables in order.

PinkMilk 02 May 2020 23:01

Template:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Plugin:
hook : parse_templates

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Note: This is just a randon guess!

Dr.CustUmz 02 May 2020 23:32

Quote:

Originally Posted by PinkMilk (Post 2602779)
Template:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Plugin:
hook : parse_templates

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

Note: This is just a randon guess!

thanks pink, i did something similar, been reading through alot of articles on here to find anything similar. I ended up doing it all in the plugin since im calling multiple varibles throughout the html code as well.

so my end results ended up being along these lines:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

then just used the $cantTellYa variable in the template, this seems to work well, there are multiple spans and variables in the code, i just shortened everything to display it here.


All times are GMT. The time now is 11:17.

Powered by vBulletin® Version 3.8.14
Copyright © 2021, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.