I am trying to load the Vzaar libraries into Codeigniter. Should these file go into the libraries directory. If so there are multiple files, which one would I make the call to from my controller. I believe the main library file is Vzaar.php. Therefore should my call be
$this->load->libraries('Vzaar');
Presumably this library is a standard PHP class called Vzaar? If so, then yes, what you've said is correct. Put Vzaar.php into your application/libraries folder and load it up at any time using $this->load->libraries('Vzaar'). Then you can use it by doing $this->Vzaar->myFunction(). For more info, check out CI's awesome user guide:
http://codeigniter.com/user_guide/general/creating_libraries.html
Yes, $this->load->libraries('Vzaar') followed by $this->Vzaar::function_name() should do the job, since it's just a PHP class and it has all require_once instructions inside of it already.
Evi Skitsanos,
vzaar API Head of Support,
email: evi#vzaar.com | twitter: http://twitter.com/skitsanos
Related
I am using SS 3.02 and have made a lots of modification in the core files. I am facing the issue that I am trying to set the color of the navigation background dynamically. This works fine for pages other than security/login page. Suppose I am getting the value in $navbgcolor, this shows up well on home page or about us page or any other page. But this does not show up on the Security/login page. Any help would be greatly appreciated. Thanks.
Firstly, it is never a good idea to alter the core files as this prevents you from easily updating your version of SilverStripe. You could miss out on bug fixes and important security updates.
The reason this isn't working on the login page is because the login page works from the Security controller which directly extends Controller. Your code (presumably in Page_Controller) will be completely bypassed.
Here is a way you could apply your code to all controllers, without touching the core:
<?php
class MyControllerExtension extends Extension {
public function onAfterInit() {
//... Your code here...
}
}
In your config file you would apply your new controller extension to Controller.
If you're using _config.php
Object::add_extension("MyControllerExtension", "MyControllerExtension")
If you're using YAML (recommended)
Controller:
extensions:
- 'MyControllerExtension'
You can learn more about extensions here: http://doc.silverstripe.org/framework/en/reference/dataextension
Also to let you know, you can create specific template file for the Security login pages by creating action sub-templates. Example is if you created a file in your theme called "Security_login.ss" you can call in variable, change the mark up etc.
Note the convention here is the filename is called the name of the class in this case "Security" then "_" followed by the name of the action to be rendered by your controller ("login" in this case).
As mentioned by micmania1, the golden rule for developing in SilverStripe is...
"Don't hack the core or modules!"
Instead as pointed out use extensions to decorate classes, or use subclasses if you have to.
I have a plugin and inside the plugin I have a Lib folder.
Like this:
Lib/Billing/CMS/CMS.php
How can I use the CMS class inside CMS.php on my controller? Not my plugin controller, but a controller on my application.
EDIT: Cake version is 2.3
So, from your short information one can only guess...
Your plugin is "Billing"?
Your files are
APP/Plugin/Billing/Lib/CMS/CMS.php (class CMS)
APP/Plugin/Billing/Lib/Billing.php (class Billing)
You include classes always the same, using App::uses().
Then its
App::uses('CMS', 'Billing.CMS'); // Filename, Plugin.Package
and
App::uses('Billing', 'Billing.Lib'); // Lib as package namespace here due to lack of a proper one
I do not have to point out, that you need to load your plugin first, right?
Using CakePlugin::load()/loadAll()
I've looked through all of the CI documentation, and done some Googling of it, but I still can't quite seem to figure out how to create a configuration file for a custom library in codeigniter. If somebody could even just point me in the direction of where in the docs I could find my answer it would be greatly appreciated.
I am creating a library in CI that makes use of several database columns that can vary in name between applications, so I would like the names to be stored in a custom config file. Then I would like to be able to load these values in the construct of the library.
So my two questions are:
1.) How do I name the config file, and how do I name variables within that file so they don't overwrite any other config vars?
2.) How do I get the values from within my library?
When i have questions like this i like to look at other projects that already do this. We utilized Tank_auth in almost all of our ci projects. This is a popular authentication library, which has its own custome config files
It just creates its own config file in application/config directory.
You could prefix your config items with your app name to ensure that they are unique
it then just loads it in the constructor:
$this->ci->load->config('tank_auth', TRUE);
If there is a config/libraryname.php file, it will be automatically loaded, just before library instanciation.
(so, beware of name conflicts with CI's config files)
Side note: this autoloading is disabled if you pass an array as the 2nd argument:
$this->load->library('thelibrary', array('param1' => 'value1'));
in your config /config/your_conf.php:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$config = Array(
'your_conf1' => 'your_conf_val1',
'your_conf2' => 'your_conf_val2',
'your_conf3' => 'your_conf_val3'
);
in your controller:
$this->config->load('your_conf');
var_dump((array)$this->config); //show all the configs including those in the your_conf.php
I am newbie to the zend framework.
I want to know how to includes files in zend framework views.
I am using index.phtml to show the data in zend framework.
index.phtml contains some php pages like:
require_once ('/_incl/functions.php');
include('../functions.php');
Now I want to know where I put these files and call to index.phtml page.
What I can do to include these files, means where is the right place to keep all these files, and call from index.phtml page.
I totally understand how it feels to be a newbie.
No, you do not INCLUDE anything. If there is something you want to happen but have no option for it in zend, you make your own library and structure the class names accordingly. For example:
Zend_Form_Element is a class which is Zend / Form / Element.php
What you do is, make a class file and then, compile it.
To get started I would recommend going through this tutorial on tutsplus.
http://net.tutsplus.com/tutorials/php/zend-framework-from-scratch/
So, make a controller , make views, pass values from controller and then echo it in views.
Try to follow the rule-book rather writing codes in traditional method. :)
Hope you learn faster :)
I have simple way to include file in zend view page.
Just create one folder named 'include' inside public folder and store the file which you want to include.
After that write the following line in above the page where you want to include the file.
**include_once "./<include folder name>/<include file name>.php";**
Thanks......p2c
1- How can I register and call my plugin in bootstrap file?
2- Is it a better way to use boostrap file intead of application.ini file for registering and calling my plugins ?
Note: Iam using custom path ('Mylib/Controller/Plugin') for storing my plugins.
Actually I want to convert following 'application.ini' entries
autoloaderNamespaces[] = "Mylib_"
resources.frontController.plugins.CheckHasAccess = "Mylib_Controller_Plugin_CheckHasAccess"
into bootstrap _initPlugin function.
Can some one guide me in this regards with some sample code.
Thanks in advance
1 - You would need first to load your plugin class (via Zend_Loader or require_once)
then create your plugin yourself:
$plugin = new MyPlugin();
then you can call any public method of your plugin you want and at the end you can register it within front controller:
Zend_Controller_Front::getInstance()->registerPlugin($plugin);
2 - if your plugins need to be somehow configured before they can be used by framework - then you can create and configure them yourself (as described above). If they don't need any special actions - then you can let them to be created by Framework automatically.