Welcome Guest, Not a member yet? Register   Sign In
Simple tool for Scaffolding to manage all tables faster
#11

[eluser]sophistry[/eluser]
forgive me for correcting the english, (assuming you are spanish speaking with a name like eljunior! - el modo subjunctivo es dificil en inglés también:

instead of what you have above... these small corrections make it sound perfect (and still funny like the original!):

I forgive you for making it look like you were using this and you forgive me for not explaining the problem in detail… (though maybe I would not have done this in the first place, if you hadn’t done that. :-D :-D)

well, I think it’s better if I try to find another way to do this, then…
#12

[eluser]eljunior[/eluser]
oh, no! I already forgave you once, now I'll have to forgive you one more!

correcting my english is ok, but assuming I'm spanish... (soy brasileño, ¡hombre viejo! Smile pero no te preocupes, me gustaría mucho ser uruguayo... :-D y mi nombre es "Elias Junior", por eso "eljunior". ;-))

thanks for the corrections, it actually looks funnier when corrected... Smile

well, since you seems to use CI seriously and I've got your attention, I'd like some
advice in the following (I know it's not the appropriate thread, but if this turns in
something good, we'll create a thread for it):

I wanted to be able to use a dropdown for the foreign keys in scaffolding,
so I created this method in system/scaffolding/Scaffolding :

Code:
function _prepare_field_data($field_data)
        {
                foreach($field_data as $i => $field){
                        $table=null;
                        if(ereg('_id$',$field->name)){ // matches table_id
                                $table=ereg_replace('_id$','',$field->name);
                        }
                        if(ereg('^id_',$field->name)){ // matches id_table
                                $table=ereg_replace('^id_','',$field->name);
                        }
                        if(! ($table && $this->CI->db->table_exists($table)) ){
                                continue; // isn't a reference, skip it
                        }

                        $options = array(); // sets up an array of options
                        $query=$this->CI->db->get($table);
                        foreach($query->result_array() as $row){
                                // this assumes that first field is id,
                                // followed by a field description
                                $options[ current($row) ] = next($row);
                        }

                        $field_data[$i]->options=$options;
                        // changes field type for testing in the view
                        $field_data[$i]->type='reference';
                }
                return $field_data;
        }

and called it from methods add:
Code:
'fields' => $this->_prepare_field_data($this->CI->db->field_data($this->current_table)),

and in method edit:
Code:
'fields'        => $this->_prepare_field_data($query->field_data()),

and finally added an elsif in the views for showing the dropdown:
Code:
<?php elseif ($field->type == 'reference'): // cont. acoxambre EDSJ ?>
        <td>&lt;?  echo form_dropdown($field->name,$field->options); ?&gt;</td>

now, I want to know if this thing is a good practice, if there are problems in this approach
or if it makes sense to have something like this in CI and if CI is likely to have something like that, and if it can be good just for me, or if you could use something like this,
and probably more questions, depending on your answer... :-D

¡muchas gracias, muchacho!
y ¡feliz navidad! :-D
#13

[eluser]sophistry[/eluser]
haha... well, actually, i didn't assume you were "spanish" only "spanish speaking" (which is *way* different and in my mind something of a compliment! ;-) )

regarding your foreign key approach... here are a few thoughts in random order:

in general, i believe that changing core files is not a GoodIdea; that sentiment is echoed throughout the CI forums. things change and then your mods break and it's annoying.
scaffolding in CI is useful but, not something to build an application around. i think there are other approaches with similar (development-easing) results. the "Rails Inspired Active Record" thread comes to mind. http://ellislab.com/forums/viewthread/61192/
i personally would not use this approach - i typically write small applications with highly customized interfaces for each one and i only rely on scaffolding for the managing the first few test datapoints.

HTH.
#14

[eluser]eljunior[/eluser]
yeah, yeah, well I'm not spanish spanish, though I sometimes try to be a spanish speaking or a spanish singing, I don't know which one I fail best...
but thanks for the something of a compliment in your mind, anyway! :-D

and "yeah, yeah" again, I know that scaffolding is just something to easily create some data faster
when in development phase (I use to do this in the mysql prompt, so scaffolding help to go a little faster),
I just thought that could be a little easier having a dropdown instead of a simple input text for
"the first few test datapoints"... Smile

the major problem with this stupid idea of mine is what you have said about the core files...
anyway, it's stupid... but I think will keep using it until it gets broken, cause I'm stupid as well! Big Grin

thanks again!
HAPAH. <- ("Hope Another Palindrome Acronym Helps", if you guessed it, won a cookie!)
#15

[eluser]Unknown[/eluser]
I found problem like #6 so I have an idea to fix it by using session .

Code:
parent::Controller();    

$this->load->library('session');
if(!$this->uri->segment(3) == '') {
        $seg3 =  $this->uri->segment(3);
        if($seg3 !="add" &&  $seg3 !="view" && $seg3 != "edit" && $seg3 != "delete")
                $this->session->set_userdata('scaffolding_tbname', $this->uri->segment(3));
        $this->load->scaffolding($this->session->userdata('scaffolding_tbname'));
}
#16

[eluser]sophistry[/eluser]
guys, heads up! scaffolding is deprecated in version 1.6

http://dev.ellislab.com/svn/CodeIgniter/...gelog.html
#17

[eluser]crimsun[/eluser]
Hello All,

I am MCA Fresher And i am currently working in code igniter. I am very thankfull to whoever post the sample code and proper guideance for scaffolding but i have one problem while i implement that in my project it gives me warninig like

A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /opt/lampp/htdocs/demo/system/application/controllers/demo.php:37)

Filename: helpers/url_helper.php

Line Number: 541


So please suggest me any solution if u have for this....

Once again
Thanks to all....
#18

[eluser]sophistry[/eluser]
[quote author="sophistry" date="1200987984"]guys, heads up! scaffolding is deprecated in version 1.6

http://dev.ellislab.com/svn/CodeIgniter/...gelog.html[/quote]

hi Sanju..South, welcome to CI.

thank you for posting, but (as you can see from this quote from early 2008) this thread is pretty much not alive anymore. you will get a better response if you create a new thread.

also, i'm absolutely sure that nobody in this forum wants to help you with a feature that has been deprecated for 2 1/2 years and is now completely removed from CI.

my advice is to not use scaffolding.

good luck.
#19

[eluser]Ignazio Setti[/eluser]
Hi all,

i noticed that appending an extra parameter to the END of the uri leaves automatic scaffolding routing intact and working, like so:

http://www.yourhost.com/controller/secret_word/[parameter]

You can than retrieve it and load scaffolding accordingly:

Code:
$total = $this->uri->total_segments();
switch ($this->uri->segment($total))
{
    $this->load->scaffolding('your_custom_table_name');
}

Now, it would be cool to modify class behaviour without messing with Scaffolding.php, i took a look and the uri part doesn't seem so complex.
#20

[eluser]liu yiyi[/eluser]
Thank you ~!! Your share




Theme © iAndrew 2016 - Forum software by © MyBB