Welcome Guest, Not a member yet? Register   Sign In
few questions form rookie
#1

[eluser]Przemek[/eluser]
Hi,
I'm new in codeIgniter and i have few questions abut scaffolding, and load views.
1) scaffolding can I pre per few scaffolding to work in one website ? like:
Code:
$route['scaffolding_trigger'] = "laduj";
$route['scaffolding_trigger'] = "kom";
and turn on
Code:
$this->load->scaffolding('news');
$this->load->scaffolding('kom');
it didn't work for me so I ask is possible to have few them to manage multiple entry's in database ? and if yes how ?

2) is its possible to load into one view multiple variables ? like
Code:
$data['query']=$this->db->get('news');
        $linki['glowne']=array("nowosci"=>'Nowości',"sklad"=>'Skład',"tabela"=>'Tabela');
        $this->load->view('drozyna_nowosci',$linki,$data);
and also is it possible to have a default loading variables ??

thanks in advance
#2

[eluser]pistolPete[/eluser]
Quote:1) scaffolding can I pre per few scaffolding to work in one website ?

This is not possible since you overwrite the first trigger whith the second one.

Please be aware of the following: User guide
Quote:Scaffolding has been deprecated from CodeIgniter as of 1.6.0.
I'd rather write some own controllers/functions in order to gain the needed flexibility.

Quote:2) is its possible to load into one view multiple variables ?

Of course, just put them all in one associative array.
Read the user guide: http://ellislab.com/codeigniter/user-gui...views.html
#3

[eluser]jedd[/eluser]
Hi Przemek and welcome to the CI forums.

Scaffolding

... is pretty much deprecated now, and wasn't ever hugely encouraged by the sounds of it Wink, so you're better off finding an alternative. Two paths you can take - something like phpmyadmin (web front end) which seems very popular around here, or (my preference) writing up your schema and insert data into a bunch of text files. I like the latter approach because you can engineer your test data sensibly, and easily re-create your base set of data with one or two 'source' commands.

Multiple data to a view

Instead of doing this:
Quote:2) is its possible to load into one view multiple variables ? like
Code:
$data['query']=$this->db->get('news');
$linki['glowne']=array("nowosci"=>'Nowości',"sklad"=>'Skład',"tabela"=>'Tabela');
$this->load->view('drozyna_nowosci',$linki,$data);

... try this:
Code:
$data['news']=$this->db->get('news');
$data['glowne']=array("nowosci"=>'Nowości',"sklad"=>'Skład',"tabela"=>'Tabela');
$this->load->view('drozyna_nowosci',$data);

In your view you'll have $news (your query results) and $glowne (your array).


Quote:and also is it possible to have a default loading variables ??

Yes, but you'd need to describe what by you mean a bit better.

If you have just one or two variables that you want to set, try config/config.php

If something larger, with perhaps some logic wrapped around them, there's several places.
#4

[eluser]Przemek[/eluser]
Thanks i used $data as one array it works very well.
About scaffolding, i will need to write other admin sub page to manage that.
Thanks for info.

ps. about that deflaut
I have code like that
Code:
function nowosci()
    {
        $data['query']=$this->db->get('news');
        $data['glowne']=array("nowosci"=>'Nowości',"sklad"=>'Skład',"tabela"=>'Tabela');
        $this->load->view('drozyna_nowosci',$data);
    }
    function sklad()
    {
        $data['glowne']=array("nowosci"=>'Nowości',"sklad"=>'Skład',"tabela"=>'Tabela');
        $this->load->view('drozyna_sklad',$data);
    }

and as you might see i write 2 times
Code:
$data['glowne']=array("nowosci"=>'Nowości',"sklad"=>'Skład',"tabela"=>'Tabela');
can i put it in some kinda deflaut place so its load always.
like
Code:
class drozyna extends Controller {
    function drozyna()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->scaffolding('news');
    }
.....
}
#5

[eluser]Przemek[/eluser]
Also you spook about security.
I want create admin panel tell me plz am i right.
I create function in my controller
Code:
function admin()
    {
        $this->load->view('admin');    
    }

its loading a file when i prompt password, next is loaded second page from function
Code:
function admin_loguj()
    {
        if($_POST['haslo']=="pass")
        {
            $pass['pass']="qwer";
            $this->load->view('admin_loguj',$pass);
        }
    }
were i check that password and create new one witch is passed as array to file admin_loguj there i check $pass and if its ok its load and there i have all admin content
is it ok or code igniter have some build in admin function
#6

[eluser]jedd[/eluser]
Reducing repetition

Yup, you can put it in your constructor, which is the logical place if you're using this array in one controller only. If you're using it in more than one controller(?), then there are better places.

So you'd have:


Code:
class drozyna extends Controller {
    function drozyna()
    {
        parent::Controller();

        // libraries and helpers
        $this->load->helper('url');
        $this->load->scaffolding('news');

        // Variables
        $this->data['glowne']=array("nowosci"=>'Nowości',"sklad"=>'Skład',"tabela"=>'Tabela');
    }
}

In your methods, you'd then use $this->data rather than $data -- read up on variable scope on the PHP web site, as this is an important distinction to understand.
#7

[eluser]jedd[/eluser]
[quote author="Przemek" date="1250703388"]
were i check that password and create new one witch is passed as array to file admin_loguj there i check $pass and if its ok its load and there i have all admin content
is it ok or code igniter have some build in admin function[/quote]

Wow.

Uhm, CI has no built-in admin or auth function - a topic of discussion that comes up regularly around here. You may want to check out [url="https://github.com/jedd/User-Library"]thody's User-Library[/url] if you're after a basic system you're happy to hack.

As far as I can tell, though, your authorisation process here is simply to check if the password has been supplied on the URL, is that right? Do you have a user table in your database already?
#8

[eluser]Przemek[/eluser]
Well...
It will be only administration of content no user controll so no database conection there.
There will be form were you input password witch is cheked in controller, then will be load admin page witch password protected that is add on web page
Code:
function admin_loguj()
    {
        if($_POST['haslo']=="pass")
        {
            $pass['pass']="qwer";
            $this->load->view('admin_loguj',$pass);
        }
    }
and in page admin_loguj.php will be some think like that
Code:
if($pass==qwer){
admin content
}
else exit
is that make sens ??




Theme © iAndrew 2016 - Forum software by © MyBB