Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Path Variable
Xarcell
✭
I'm new to vanilla and not very good with php. I'm trying to create a plugin. My question for now is how do I proper the proper absolute path? Is a variable used, or something else?
For example how do I get the:
/home/public_html/blah/blah/blah/
Is something similar to this used?
$path/blah/blah/blah/
0
Comments
dirname(__FILE__)
is the absolute path of the directory you are currently in, or the directory that the current script is executing from to be precise.so you can do
include_once(dirname(__FILE__).DS.'class.somemodel.php');
you also have various cosntants in Garden
DS
is the director separator.grep is your friend.
I'm trying to wrap my head around what your saying. I understand half of it. However, I don't need to point to a file(include), I need to point to a directory where files are to be deposited.
Example:
// files storage folder
$dir = '/home/web/sitecom/plugin/images/';
So would it be something like this?
define('PATH_ROOT' . 'plugin/images/') = $dir;
FYI, I cannot get this stupid editor to display code properly.
I would take a more general course in php, so you get a better overall understanding. Also any C based language will help.
if the script is already in the directory you can use
define('MY_IMG_DIR' , dirname(__FILE__).DS.'images');
or
define('MY_IMG_DIR' , PATH_PLUGINS.DS.'MyPlugin'.DS.'images');
grep is your friend.
define is just setting a CONSTANT rather than a variable (which can change)
http://php.net/manual/en/function.define.php
so when you use it it,
after you define it.
you don't use the $ as you would in $my_img_dir
you would use MY_IMG_DIR
as in echo MY_IMG_DIR;
vs a variable
echo $my_img_dir;
and you would want a relative path not an absolute path if you plan on uploading the plugin so other can use.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I'm just trying to get this script to work as part of the editor plugin.