We have a custom package (puc) that we created that includes a few asset types as well as a content type. This works really well with the automatic upgrade scripts because we can add the puc package to the skip list and it gets left alone. There is just one problem, we have some lib files that we store in core/lib which are using within one of the assets. Is there a way to include lib files in the package so that they don't get replaced during upgrades and we don't have to manually move them back to the correct location? Such as storing inside the package directory and still have linking work?
Thanks.
Package including lib files?
You can include them in the package in a [PackageName]/Libs directory and then reference them from in there rather than in the main libs dir. Or do you need something more complicated?
[quote]
You can include them in the package in a [PackageName]/Libs directory and then reference them from in there rather than in the main libs dir. Or do you need something more complicated?
[/quote]
Thanks Greg, I see that the calendar package does what I want. So to include the files I need I see I can use:
require_once SQ_PACKAGES_PATH.'/puc/lib/my_file.inc';
But, what about files that need to be accessible from the web such as images and .js files? It looks like the calendar package has these as well, both .js and .css files. Then in the code they are referenced like:
How do those files which are in the package get moved into the asset_types folder? Does this happen during step_03.php? Or do I need to do something else?
[quote]
But, what about files that need to be accessible from the web such as images and .js files? It looks like the calendar package has these as well, both .js and .css files. Then in the code they are referenced like:
How do those files which are in the package get moved into the asset_types folder? Does this happen during step_03.php? Or do I need to do something else?
[/quote]
Yep, it is step 3, look in the page_calendar_management.inc file to how it includes extra files.
[quote]
Yep, it is step 3, look in the page_calendar_management.inc file to how it includes extra files.
[/quote]
I want to add all files and folder recursively within my lib folder. The following function will provide an array with all of the paths, would doing it this way be ok?
/** * Gets a list of all files that we want web accessable * * @return array * @access private */ function _getFileList() { $str_path = '/path/to/files/'; $path = realpath($str_path); $items = Array(); $objects = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach($objects as $name => $object){ $full_path = $object->getPathname(); $shorten = str_replace($str_path, "", $full_path); $items[] = $shorten; } return $items; }//end _getFileList()
[quote]
I want to add all files and folder recursively within my lib folder. The following function will provide an array with all of the paths, would doing it this way be ok?
/** * Gets a list of all files that we want web accessable * * @return array * @access private */ function _getFileList() { $str_path = '/path/to/files/'; $path = realpath($str_path); $items = Array(); $objects = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST); foreach($objects as $name => $object){ $full_path = $object->getPathname(); $shorten = str_replace($str_path, "", $full_path); $items[] = $shorten; } return $items; }//end _getFileList()
[/quote]
The function looks ok, but you might have to add extra filtering to remove current directories(.), directories or any versioning files (if you use them). I don't think you need to make directories publically accessible, just the files you want exposed. For example, if you have:
./somedir ./somedir/main.js ./somedir/otherdir ./somedir/otherdir/second.js
you would only pass back:
./somedir/main.js ./somedir/otherdir/second.js
and I am pretty sure the installation will handle the directories for you. Hope that helps and makes sense!
[quote]
and I am pretty sure the installation will handle the directories for you. Hope that helps and makes sense!
[/quote]
Thanks, I think I can take it from here.