Codeigniter: using libraries in controller? - codeigniter

I want use my library function in controller file. Is it possible ? Thanks..

Not sure what you mean. If by that you mean "Can I write my own libraries and call them from a controller in CodeIgniter", the answer is yes.
I suggest take a look at this page in the CodeIgniter documentation for further details.

Related

Is there anything in Laravel equal to enable_profiler() in CodeIgniter?

The CodeIgniter Profile Class will display benchmark results, queries you
have run, and $_POST data at the bottom of your pages. This
information can be useful during development in order to help with
debugging and optimization.
Is there anything in Laravel equal to $this->output->enable_profiler(TRUE); in CodeIgniter?
No, there is no such built-in feature. You have to use some external package for that, like:
https://github.com/barryvdh/laravel-debugbar
https://github.com/daylerees/anbu

Joomla - using ajax in custom module

Requirments: I can't use components and ajax interface (joomla com).
My goal: Send POST data from default.php (mod_x) to helper.php (mod_x). Data is checked checkboxes - using ajax.
How to do this?
I know there has to be a method, to do this directly (can someone give me an example), by removing (I know its security risk, but there has to be a way to secure it by hacking joomla)
defined('_JEXEC') or die('Restricted access');
Is there some way to give a module task - just like you can do using component (controller)? I can't use component myself. How would this be done? Please be explicit.
Is there any other possible way? There has to be... I'm ready for some serious brain-storm. Let's get creative, guys.
P.S. To sum it up, I try to find some creative way to not use components, just module to do ajax call from default.php (ajax runs on checked checkbox/s)
I would prefer also an example in code. Thank you!
Fron Joomla 3.2 if you needed to make an AJAX request in Joomla! from a custom module or plugin, you can build the URL as below.
index.php?option=com_ajax&module=your_module_name&method=YourMethodName&format=json
Explanation of each parameter
1. index.php?option=com_ajax : ALL requests must be routed through com_ajax.
2. module=your_module_name: The first part of this is the type of extension you're using. This can either be 'module' or 'plugin'. The second part is the name of the extension. please take care you're not including the prefix 'mod_' or 'plg_', just the name.
3. method=YourMethodName: This is the method name that you are trying to call. If you're using this in a module then the method must be appended with 'Ajax'. So, the method represented here will be YourMethodNameAjax. If you're using this on a plugin, the method must be prepended with 'onAjax'. So, the method represented here will be onAjaxYourMethodName.
Check more at Joomla doc

How to manage URLs in CodeIgniter so they can be updated in a single place

I believe Smarty templates has functionality built in that allows you to manage your site URLs from a config file so if something gets moved, you only have to update the URL in one place. Does this sort of functionality exist in CodeIgniter? If not, any pointers or examples on how/where to add it?
For example:
Instead of hard-coding the link it would be: Settings
But where would you want to set $links so that it was available everywhere? Or is it really best to just hard code them?
Take a look at the config class. It allows you to make custom config files.
It's not entirely made for URL's but you sure can use them.
The base url should be basically right at the start of /app/config/config.php, where app is the name of your codeigniter application folder. You access it through calls to the base_url() function.
Yes, it's called Routes, configuration located at config/routes.php. Documentation
If you ask about the rendered html of the links, then your best bet would be using site_url() in conjunction with constants, for example site_url(URL_SETTINGS);, there is no built in functionality for that, but I can say I don't think that is necessary as it would be used too rarely, but it would influence performance every single load.

Getting started with Phil Sturgeon's CodeIgniter Template library

I'm trying to use Phil Sturgeon's CodeIgniter Template library, but I can't get it to change my pages. I read the documentation, followed the steps there,
Download
Copy to application folder
Create a views/layouts/default view
(Auto)load the library
however, it is not clear as to how the template is actually implemented. I thought that loading the view would apply the template everywhere, but it doesn't seem to work that way. I've also read about it in the CodeIgniter Wiki, but it looked too complicated to be the right answer.
How are you supposed to use Phil Sturgeon's Template with your controllers? (or views?) Am I missing something here?
It does not overload the load->view() methods, that would be bad. You need to update your controllers to use the template's syntax and methods in every instance you want to use it:
http://philsturgeon.co.uk/demos/codeigniter-template/user_guide/
You will use $this->template->build() instead of $this->load->view() in most cases, after constructing your template by defining regions, setting titles, etc.
There should have been a user guide included in your download with examples.

CodeIgniter Help

I am trying to build an autosuggest using CodeIgniter, can i have some examples?
Try their video tutorials. They show you how to make a blog and a basic introduction to CodeIgniter.
Also, they have another list of tutorials that might give you a better idea.
Have a look at the PHP form_helper that shows you how to add javascript events and PHP callbacks on to form elements both of these you will need to use to work.
Good Luck

Resources