Error using Custom Helpers in CodeIgniter

There is something I don't get in the creation of custom helpers in CI...

I've the docs, but it doesnt seem to really ever show how to format the functions in the helper.

Am I supposed to put the code inside php brackets, or simply use function code ? Because right now, If I try to put the functions I want to use inside the php brackets in the helper file, it will show an error and refuse to load.

<?php
public function build_Home($page_Name,$rank,$thread,$sector)
    {
    $data['CSS'] = "css/style_centre_paiement_paiements_1.css";
    $data['PAGE_NAME'] = "css/style_centre_paiement_paiements_1.css";
    $data['RANK'] = "css/style_centre_paiement_paiements_1.css";
    $data['THREAD'] = "css/style_centre_paiement_paiements_1.css";
    $data['FULL_NAME'] = "css/style_centre_paiement_paiements_1.css";
    $data['SECTOR'] = "css/style_centre_paiement_paiements_1.css";

    $this->load->model('Privileges_model');
    $rank_ID = $this->Privileges_model->gather_Rank_ID($rank);
    $page_ID = $this->Privileges_model->gather_Page_ID($page_Name);
    $privilege = $this->Privilege_model->gather_Privileges($page_ID,$rank_ID);

    switch ($privilege) {
case "admin":
    echo "i égal 0";
    break;
case "paren":
    echo "i égal 1";
    break;
case "anima":
    echo "i égal 2";
    break;

    $data['C1'] = "<li><a class='' href='www.google.ca' ></a></li>";
    $data['C2'] = "css/style_centre_paiement_paiements_1.css";
    $data['C3'] = "css/style_centre_paiement_paiements_1.css";
    $data['C4'] = "css/style_centre_paiement_paiements_1.css";
    $data['C5'] = "css/style_centre_paiement_paiements_1.css";
    $data['C6'] = "css/style_centre_paiement_paiements_1.css";
    $data['C7'] = "css/style_centre_paiement_paiements_1.css";       
    }
?>     

The function is obviously not completed so don't mind it. What you should mind, though, is that this doesnt work in the file. It shows an error.

Am I supposed to put a class header ?

Answers


I think it is the use of keyword public in function declaration that's giving you the error. Since a helper file contains a list of plain functions, you don't use public there. Just omit it and your helper should work fine.


Need Your Help

JXL Support for excel 2007 format

jxl

I my app, I have used JXL to parse XLS sheets.

Random images and text with query mobile

jquery arrays mobile random

I have some code that I am using to generate a random image when the initial screen image is clicked (found on JavascriptSource):

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.