Package block runs to another directory php of a file.
Permalink
Hello!
I want to run a file in block another directory
package
directory name
controller.php
directory name
blocks
directory <--- how can run php of a file?
a directory
a.php
b directory
b.php
c directory
c.php
add.php
controller.php
db.xml
form_setup_html.php
view.php
Click select option to choose for a to c of directory at block's form_setup_html
I have made to this select option for pick up directory a or b or c with working. But the files of a, b, c are access denied.
Any ideas on how to work this?
Sorry this is not my first language. I use British Sign Language first.
If any one can help, thank you.
I want to run a file in block another directory
package
directory name
controller.php
directory name
blocks
directory <--- how can run php of a file?
a directory
a.php
b directory
b.php
c directory
c.php
add.php
controller.php
db.xml
form_setup_html.php
view.php
Click select option to choose for a to c of directory at block's form_setup_html
I have made to this select option for pick up directory a or b or c with working. But the files of a, b, c are access denied.
Any ideas on how to work this?
Sorry this is not my first language. I use British Sign Language first.
If any one can help, thank you.
Great. Thank you very much. I will try. Hope will be work.
I am not sure if I was right.
For example:-
In view.php:-
Loader::library('another/my_class', 'package_handle');
$another_my_class = new AnotherMyClass();
echo $another_my_class;
In package_handle library
my_class.php:-
public function AnotherMyClass(){
$hello = t('Hello');
return $hello;
}
I have test this but error message says 'syntax error, unexpected T_PUBLIC'
For example:-
In view.php:-
Loader::library('another/my_class', 'package_handle');
$another_my_class = new AnotherMyClass();
echo $another_my_class;
In package_handle library
my_class.php:-
public function AnotherMyClass(){
$hello = t('Hello');
return $hello;
}
I have test this but error message says 'syntax error, unexpected T_PUBLIC'
I just have found. Remove 'public'
Now working :-)
Now working :-)
$this->get ? () for package-->libraries
I can't find this for information from Concrete5 :-(
Anyone can help? Thanks
I can't find this for information from Concrete5 :-(
Anyone can help? Thanks
$_SERVER['DOCUMENT_ROOT'].DIR_REL.'/packages/package_handle/libraries/
Its option select working with the links of libraries folder. I use this code below:-
<?php $dir = $_SERVER['DOCUMENT_ROOT'].DIR_REL.'/packages/package_handle/libraries/'; ?>
<select>
<?php
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "<option value='$entry'>".$entry."</option>";
}
}
closedir($handle);
}
?>
</select>
Its option select working with the links of libraries folder. I use this code below:-
<?php $dir = $_SERVER['DOCUMENT_ROOT'].DIR_REL.'/packages/package_handle/libraries/'; ?>
<select>
<?php
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "<option value='$entry'>".$entry."</option>";
}
}
closedir($handle);
}
?>
</select>
If the directory is a subdirectory of your block, $this->inc() in edit or view.
If the directory is elsewhere in the package, it needs to be /elements, /libraries, /models, /helpers
You can then load correctly named classes or files within those directories using the applicable loader such as
Files & classes need to follow the c5 naming conventions for this to work.
If you want to use further directories
Elements work a bit differently because they are just sequential code, not classes.
There is plenty of info in the documentation.