Questions tagged [codeigniter-helpers]

Rogue functions who don't belong to a class, but can be grouped by their final purpose in CodeIgniter.

Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular category. There are URL Helpers, that assist in creating links, there are Form Helpers that help you create form elements, Text Helpers perform various text formatting routines, Cookie Helpers set and read cookies, File Helpers help you deal with files, etc.

17 questions
190
votes
7 answers

CodeIgniter: Create new helper?

I need to loop lot of arrays in different ways and display it in a page. The arrays are generated by a module class. I know that its better not to include functions on 'views' and I want to know where to insert the functions file. I know I can…
Jonathan
  • 8,676
  • 20
  • 71
  • 101
11
votes
2 answers

Is there a difference between the method of helper and library are called upon in code igniter?

I am getting little bit confused, the way the methods of library and helper are used in code igniter. I am still learning code igniter. CONTROLLER function index(){ $this->load->helper('text'); $this->load->library('auth'); //custom…
Nirmalz Thapaz
  • 925
  • 4
  • 13
  • 28
7
votes
4 answers

CodeIgniter helper in the view

Is it a good workaround and would it be possible to use helper classes in the view, in CodeIgniter. I have a situation when I have to extract with regulars expression from a text couple of strings and generate outputs on matches. I would not like to…
fefe
  • 8,755
  • 27
  • 104
  • 180
2
votes
3 answers

equivalent function for $this->_ci_cached_vars in CI Helpers

I'm creating a custom helper in codeigniter. There is an instance where I check if certain parameter is passed to view. In view, i can get all the passed variables by using this function: $this->_ci_cached_vars but it returns blank when used in…
Emman Z
  • 171
  • 1
  • 13
1
vote
1 answer

Dynamic Meta tag through helper or library for each function or for each page in codeigniter 3

Hi i want generate dynamic Meta tag through helper or library in codeigniter 3 I am creating static website without model. I have - Header.php - which have header part and meta tags. middle_page.php footer.php if i am calling meta() html helper…
codegeek
  • 230
  • 1
  • 3
  • 12
1
vote
2 answers

Do I use a helper, library or place my datepicker code in a model in codeigniter?

Heres my code: //Setup days $data['days']['FALSE'] = 'Day'; //Setup months $data['months'] = array('FALSE' => 'Month', '1' => 'Jan', '2' => 'Feb', '3' => 'Mar', '4' =>…
LondonGuy
  • 10,778
  • 11
  • 79
  • 151
1
vote
2 answers

function defined in helper not found in controller

I'm using a helper function to validate XML in Codeigniter. My helper function is defined in xml_validation_helper.php and is as follows: /** * Function to generate a short html snippet indicating success * or failure of XML loading * @param type…
docaholic
  • 613
  • 9
  • 29
0
votes
3 answers

Should I extend Controller or Create Helper?

I need to access some functions in multiple controllers in a CodeIgniter application. At the moments the functions are really basic and a few, For example: generate_random_key() //just a random string is_logged() //check…
Roman
  • 3,764
  • 21
  • 52
  • 71
0
votes
1 answer

How to call a function in my_helper from routes in Codeigniter

I have a function named enable_disable(param1,param2) in my_helper.php. How can I call this enable_disable(param1,param2) from routes.php in codeigniter? Please share your great ideas if anyone have the key.
Raham
  • 4,781
  • 3
  • 24
  • 27
0
votes
2 answers

Is it okay to load models in Helpers in CodeIgniter?

I'm trying to use helpers to handle processes that involve multiple models. Is this okay in terms of best practices?
Shamoon
  • 41,293
  • 91
  • 306
  • 570
0
votes
0 answers

Helper codeigniter not calling in function ajax post

i've used codeigniter relative_time helper created by yoeran. in ajax post i call function in controller to return relative time and admin name. but relative time alwayas return null. is helper not calling in ajax post ? here my ajax code…
Ibnu Habibie
  • 721
  • 1
  • 9
  • 20
0
votes
0 answers

CodeIgniter: Creating a navigation helper

I currently have a partial called header.php which holds my site navigation among other things. Within this header site navigation is currently hard coded. This hard coded navigation could be set dynamically from the data base however. My plan is…
Liam Fell
  • 1,308
  • 3
  • 21
  • 39
0
votes
3 answers

How to generate a new URL using current_url in codeigniter

I am trying to use the current_url() function in codeigniter but not sure how to manipulate this data. I understand I can echo out the current_url() but how do I take each of the segments and use to generate a new URL? I am trying to take pieces of…
0
votes
1 answer

PHP Code Igniter Ion Auth - Can't successfully create a new tier of user

I'm rather new at CodeIgniter and especially Ion Auth. I'm building a website which will have three tiers of user: User, Moderator and Admin. My aim is to use this code snippet: if (!$this->ion_auth->in_group('moderator')) { …
Gwenji
  • 117
  • 2
  • 11
0
votes
1 answer

PHP CodeIgniter Ion Auth Creating a New Group

I am building a website and am new to Codeigniter and Ion Auth. My website consists of three tiers of user: regular user, moderator and admin. I understand is_admin and is_logged in, but can't figure out how to create a new group for my…
Gwenji
  • 117
  • 2
  • 11
1
2