Previous Thread
Next Thread
Print Thread
Hop To
Joined: Jun 2008
Posts: 92
Likes: 1
M
Journeyman
Journeyman
M Offline
Joined: Jun 2008
Posts: 92
Likes: 1
I'm creating a small class in
Control Panel > Display > General > Default Header

When I use this class in
Control Panel > Content > Forums > Forum Introduction Body

The class is "not found".

I tried making a static class (having all static members) and it was also not found.

Wouldn't the static class be globally available during the entire request?

How can I create a globally-available class for inserting some custom code?

Thanks in advance for help

Last edited by mmem700; 01/31/2019 5:54 PM.

Today they call you "crazy".
Tomorrow they call you "ahead of your time".
Joined: Apr 2004
Posts: 1,945
Likes: 145
UBB.threads Developer
UBB.threads Developer
Joined: Apr 2004
Posts: 1,945
Likes: 145
Im not sure I fully understand your question, but I'd like to bring a few things up in case they are related to what you are asking:

Headers and footers are called from within the Smarty 3.1 templates which display the pages.

note1: You cannot insert {php} or {include_php} in the templates - I believe this also affects the PHP global keyword.
SOURCE: https://www.ubbcentral.com/forums/u...e-ubb-threads-7-7-0-changelog#Post261732
Quote
[UPDATE] Removed the 2.x backwards compatibility from the Smarty library. This means faster pages all around. It also means that if you you've customized your templates to use {php} or {include_php} functions, you'll need to move those items in to your php scripts.
note2: For using JavaScript within your templates, your braces need to have spaces on either side of them, so as to not be confused by Smarty 3, as being Smarty script commands.

Anything relating to custom Smarty 3.1 code can be researched at https://www.smarty.net.


Current developer of UBB.threads PHP Forum Software
Current Release: UBBT 7.7.5 // Preview: UBBT 8.0.0
isaac @ id242.com // my forum @ CelicaHobby.com
Joined: Jun 2008
Posts: 92
Likes: 1
M
Journeyman
Journeyman
M Offline
Joined: Jun 2008
Posts: 92
Likes: 1
I'm doing something like this in the
Control Panel > Display > General > Default Header
field...

PHP Code

<?php
class myclass {
  public static function GetAPath() {
	return '/web/vhosts/orbisvitae.com/htdocs/Header.html';
  }
}
?>


and then using the class in
Control Panel > Content > Forums > Forum Introduction Body

PHP Code

<?php
// some code
$x = myclass::GetAPath();
// some code
?>


But PHP is responding saying the class is not available when calling
$x = myclass::GetAPath();



Today they call you "crazy".
Tomorrow they call you "ahead of your time".
Joined: Apr 2004
Posts: 1,945
Likes: 145
UBB.threads Developer
UBB.threads Developer
Joined: Apr 2004
Posts: 1,945
Likes: 145
It probably has something to do with security. You are attempting to run php within the Smarty 3.1 templates.

Again, you may want to look at moving your custom code in to the php scripts, and out of the templates. Thats the advice directly from Smarty 3.1

"Put your PHP logic in PHP scripts or plugin functions instead"
https://www.smarty.net/docs/en/language.function.php.tpl


Current developer of UBB.threads PHP Forum Software
Current Release: UBBT 7.7.5 // Preview: UBBT 8.0.0
isaac @ id242.com // my forum @ CelicaHobby.com
Joined: Apr 2004
Posts: 1,945
Likes: 145
UBB.threads Developer
UBB.threads Developer
Joined: Apr 2004
Posts: 1,945
Likes: 145
if your custom code worked in the old UBB.threads 7.5.x or 7.6.x, but not in UBB.threads 7.7.x, then its 100% related to Smarty 3.1 security.

UBB.threads 7.7.x removes SmartyBC (Smarty 2.x Backwards Compatibility) in favor of using the current pure version, Smarty 3.1.

But if you are still on the old UBB.threads 7.5.x or 7.6.x, then I dont have an answer.

Last edited by isaac; 01/31/2019 6:35 PM. Reason: fixed typos

Current developer of UBB.threads PHP Forum Software
Current Release: UBBT 7.7.5 // Preview: UBBT 8.0.0
isaac @ id242.com // my forum @ CelicaHobby.com
Joined: Jun 2008
Posts: 92
Likes: 1
M
Journeyman
Journeyman
M Offline
Joined: Jun 2008
Posts: 92
Likes: 1
OK... We just upgraded to 7.7.0 and are reorganizing things to make management easier because we run 2 forums.

I didn't realize that code placed in these textboxes (screencap below) were within the smarty templates.

So, is it still OK to have PHP in the "Default Header" field? If so, that will still be useful.

Thanks for the help.

Attachments
2019-01-31_17-35-10.png

Last edited by mmem700; 01/31/2019 6:40 PM.

Today they call you "crazy".
Tomorrow they call you "ahead of your time".
Joined: Apr 2004
Posts: 1,945
Likes: 145
UBB.threads Developer
UBB.threads Developer
Joined: Apr 2004
Posts: 1,945
Likes: 145
Originally Posted by mmem700
I didn't realize that code placed in these textboxes (screencap below) were within the smarty templates.

So, is it still OK to have PHP in the "Default Header" field? If so, that will still be useful.
I guess it is still is ok to have php there -

But you are trying to communicate between the two. That's ultimately where I believe you are being blocked at. Especially after reading:

Originally Posted by mmem700
Wouldn't the static class be globally available during the entire request?

How can I create a globally-available class for inserting some custom code?
If your custom code worked in the old UBB.threads 7.5.x or 7.6.x, but not in UBB.threads 7.7.x, then its 100% related to Smarty 3.1 security.


Current developer of UBB.threads PHP Forum Software
Current Release: UBBT 7.7.5 // Preview: UBBT 8.0.0
isaac @ id242.com // my forum @ CelicaHobby.com
Joined: Jun 2006
Posts: 16,292
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,292
Likes: 116
Looking at your code, if you're just trying to include an external page to pull layout elements (like what I have here) you can simply use a PHP include like:
Code
<?php include($_SERVER["DOCUMENT_ROOT"] ."/includes/header.forum.inc.php"); ?>

If I'm reading your code correctly you might be trying to include one header for two sites which may belong to different users on the machine, which could have any number of problems (such as permissions on the server); I'd advise you keep any includes local to every user, versus attempting to use only one file for various user accounts.


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Joined: Jun 2008
Posts: 92
Likes: 1
M
Journeyman
Journeyman
M Offline
Joined: Jun 2008
Posts: 92
Likes: 1
Thanks for that.

I ended up just placing an include() near the top of the ubbthreads.php file.

This includes a class that I wrote for adding a bit of functionality here and there and to stay organized. It's working well.

I will remember to re-insert it after each upgrade.

Thanks again.


Today they call you "crazy".
Tomorrow they call you "ahead of your time".

Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
spam issues
by ECNet - 03/19/2024 11:45 PM
Looking for a forum
by azr - 03/15/2024 11:26 PM
Editing Links in Post
by Outdoorking - 03/15/2024 9:31 AM
Question on barkrowler and the like
by Mors - 02/29/2024 6:51 PM
Member Permissions Help
by domspeak - 02/27/2024 6:31 PM
Who's Online Now
0 members (), 396 guests, and 110 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20230217)