News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

require(): Failed opening required

Started by IHatePHP, December 27, 2014, 01:03:00 PM

Previous topic - Next topic

IHatePHP

So, I'm creating a new theme, based off of the default, and god, the code is so messy...

Anyways, I'm reorganizing and splitting up files to clean it up a whole lot, and I can't get a simple include/require to work.

What my code looks like:
global $context, $settings, $options, $txt;
require $settings["theme_url"] . "/_before.php";


That file does exist; if I navigate to it, it shows the H1 that I placed on the file for testing. However, I get this error once the page hits the require:
Fatal error: require(): Failed opening required 'localhost/smf/Themes/indierising/_before.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\smf\Sources\Load.php(2151) : eval()'d code on line 22

Does SMF, for some reason, not allow including/requiring files? PHP Is already a terribly frustrating and broken language, but this is just weird and inexpiable. If anyone has any ideas of what went wrong, and how better to include a file in my theme, from my theme's folder, please let me know.

Burke ♞ Knight


IHatePHP

Quote from: ♞ Burke Knight ♞ on December 27, 2014, 01:06:06 PM
Why do you have an _ in the file name?

Not related to the problem, but it's a partial view; it's just a coding practice that I've picked up from my job.

vbgamer45

$settings["theme_url"] won't work should be a directory.
This would work better

require dirname(__FILE__) . "/_before.php;
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

IHatePHP

Quote from: vbgamer45 on December 27, 2014, 01:11:17 PM
$settings["theme_url"] won't work should be a directory.
This would work better

require dirname(__FILE__) . "/_before.php;


Well, it changed the error, but now it's trying to get the file from somewhere that it should'nt be:
require(): Failed opening required 'C:\xampp\htdocs\smf\Sources/_before.php'

How do I get it to include from my themes folder?

vbgamer45

is the _before.php a theme file? If so why would you have it outside of thee theme folder?
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

IHatePHP

Quote from: vbgamer45 on December 27, 2014, 01:21:54 PM
is the _before.php a theme file? If so why would you have it outside of thee theme folder?

It's NOT outside of the theme folder... I'm working on a file inside of my theme folder, trying to include another file that's also in my theme folder.

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

IHatePHP

Quote from: vbgamer45 on December 27, 2014, 01:44:04 PM
Try $settings['theme_dir'] then

thank you. I wasn't aware of the theme_dir property. Is there a list somewhere?

vbgamer45

You can do a print_r($settings) and that will print out a list of them.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Kindred

Why are you breaking everything up like that? It makes finding the correct,think to edit much more difficult and also means that your theme will never work with any mods which make template edits
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: