Welcome Guest, Not a member yet? Register   Sign In
CodeExtinguisher 2.0 Release Candidate 14.2

[eluser]Majd Taby[/eluser]
Hey guys, for those of you who wanted traditional pagination (i.e. load only 50 records at a time), i did that recently, and here is a zip file with the files i changed. This is untested and probably has bugs, but it works fine so far for me. Just replace the files in the zip with the ones you have:

http://jtaby.com/bucket/Archive.zip

[eluser]unsub[/eluser]
hello
I have come up with a solution for checking if a username (or whatever) already exists when adding records. It is written into the controller for the form in question.

I want to first warn newbies (like me) that this might be a bad way to do this, because I'm learning as I go. Copy this at your own risk, it is posted here in an attempt to get advice on how to do it better.
If one of the experts here says it's reasonable code, I will take this warning off.

To experienced code-igniters and extinguishers: I could really use some advice on this.

So, without further preamble, here is my in-controller callback solution:

first, a $rule for the field that needs checking, with a callback:
Code:
$rules['username'] = "trim|required|alpha_numeric|min_length[5]|maxlength[10]|callback_nametest";
...then at the bottom, the callback's method.
What this does is checks if the primary key is "" (nothing). If it finds a value being posted, then the current action is an 'edit', so it doesn't bother to check if the name exists - of course it does, the record is being edited. Smile
If the primary key == nothing (""), that means the current action is 'add' and so it checks if the username (in this case) being posted is already in the database:
Code:
function nametest($str){
    if($this->input->post($this->codexadmin->primary_key) == ""){
        $sql = "SELECT * FROM users WHERE username = ?";
        $test = $this->db->query($sql, array($str));
        if($test->num_rows() > 0){
            $this->codexvalidation->set_message('nametest', 'That username already exists. Please choose another');
            return FALSE;
        }
    }
}

heh...yeah. I'm not sure about this. Perhaps someone can see why I want help? Any big issues?

Don't get me wrong, it works well. I've run it through the gauntlet and it doesn't fail; but I want to make good things, not just adequate things. It's why I started using CodeIgniter.

I would really appreciate some advice on this; is it OK? any pointers on which way to go to make it better?

Thanks for your time Smile
-Gabriel

[eluser]Unknown[/eluser]
Hi

I search a detail view in this nice product. Where only the data are shown, not the list, only the data of one record.

I think it would be like the edit view, just without chance to edit. :-)

Exist there code or can somebody say me, what the easiest way for programming that is?

I tried short to understand the code, but at the moment i don't understand much.

Thanks for your help and that great product.
Lirum

[eluser]unsub[/eluser]
curious if anyone has managed to get the file / image plugins working in the 'add new' window (when using the ManyToMany or ManyToOne plugins, the extended form that is underneath, with the 'add one' button).

I've given it a shot, but I can't seem to get it to work.

also, something else about those extended forms - so far, I have been able to make them look nice by adding another .yml definition named after the database table. In a way, it's nice being able to define one form style for the main controller, and a separate one for the extended form, but if I wanted to use the same definition for both my controller and the extended form, how would I do that? anyone?
I really prefer to use controllers for my forms, so it's not an option to just use the default .yml for everything.

cheers.

To the above poster - I know how to make a popup 'record inspector' window, but I don't know how to add another page to the system so far. If the popup method interests you, post again and I'll give you a hand.

[eluser]fender21[/eluser]
I am new to CE and really CRUD in general! I found CodeExtinguisher as a great tool for a specific need I have to map out some tables with a front end. That being said, I can't figure out how to map out one full table. I have a tabled called Artists with multiple columns. I have setup a controller for Artists(assuming that is correct?). I took a copy of the UserRegistration sample to start with and the view works fine but I cannot edit or add?

What do I need to do to setup the ability to Add/Edit/Remove via this controller?

Thanks for any help! Also, is there anything like a nice screencast to setup a table from start to finish with CE? This would be extremely helpful to see the process from start to finish. I saw jTaby had a video once but it only loads about 20% of the video then stops. If I can grasp how to make this work, I'll be happy to do a screencast.


Code:
class Artist extends codexController
{    
    function Artist()
    {
        codexController::codexController();
        $this->load->helper('inflector');                
        $config = array(
                    'db_table' => 'artists',
                    'form_setup' => array(
                        'name' => array('class'=>'TextBox'),
                        'url' => array('class'=>'TextBox'),
                        'photo_link' => array('class'=>'TextBox'),
                        ),
                    'list_text'=>array('artist_id'),
                    'primary_key'=>'artist_id',
                    'page_header'=>$this->lang->line('codex_menu_userregistration'),
                    'controller_name' => 'artists',
                    );
        $this->setConfig($config);

    }
}

[eluser]Majd Taby[/eluser]
this is a slightly outdated version, but it still functions the same way, you don't need a controller, you can do everything from a YAML file, the controller is only useful if you want to extend the core of codeextinguisher

http://codeextinguisher.com/screencasts/...inguisher/

[eluser]fender21[/eluser]
Exactly what I needed jTaby! THanks!

Follow-up question, my table has an id field called artist_id (not just id). How can I tell CE to use artist_id instead of trying the default id? That's what is breaking things. I no longer have a controller, just a YAML file

[eluser]Majd Taby[/eluser]
by defining a primary_key, just like you defined form_setup and display_fields etc...

[eluser]fender21[/eluser]
Thanks jTaby! I would add Primary_Key into the YAML correct or do I have to build a controller to store the custom key?

A second question on the Editor plugin. i downloaded it and added to my plugin folder however when I call the editor in my YAML CE states:


Fatal error: Class 'jTabyForms' not found in /Applications/MAMP/htdocs/codex/application/plugins/editor.php on line 2

Do I need to something special to get the editor plugin to work correctly?

[eluser]JamesL[/eluser]
Please excuse me if this is not the place to ask general questions about CodeExtinguisher, or if this question has already been answered.

First of all let me say that this application has been very helpful and is very well put together, thank you for sharing your hard work with the community.

I have been working on a fairly simple site for a client that wants a portfolio site to show off images of his jobs. In order for the site to function properly I need to set it up so he can create new job categories and upload images by himself. I was wondering if there is a way to tell your 'Image' form input to resize the image that is being uploaded, then create a smaller thumbnail, all in one process. I worked out how to do this with a normal CI controller function, but not with CE yet. I have been passing the $config variables to the form builder through an array, like so:
Code:
$config = array(
                    'db_table' => 'carch_images',
                    'form_setup' => array(
                        'image_title' => array('class'=>'TextBox'),
                        'image_caption' => array('class'=>'TextArea'),
                        'project_name' => array(
                                        'class' => 'DbDropDown',
                                        'params' => array(
                                                'field' => 'project_name',
                                                'table' => 'carch_projects',
                                                'primary_key' => 'id',
                                                ),
                        ),
                        'filename' => array(
                                        'class' => 'Image',
                                        'params' => array(
                                                'make_thumbnail' => 'true',
                                                'thumb_marker' => '_resize',
                                                'height' => '540',
                                                'width' => '540',
                                                'url_path' => 'uploads/',
                                                'upload_path' => './uploads/',
                                                ),
                                        'class' => 'Image',
                                        'params' => array(
                                                'make_thumbnail' => 'true',
                                                'thumb_marker' => '_thumb',
                                                'height' => '40',
                                                'width' => '40',
                                                'url_path' => 'uploads/',
                                                'upload_path' => './uploads/',
                                                ),
                                ),
                    ),
                    'rules'=>$rules,
                    'list_text'=>array('image_title', 'image_caption'),
                    'page_header'=>$this->lang->line('manage_images'),
                    'controller_name' => 'manage_images',
                    );

As you can see I tried adding 2 Image classes to the filename array, without success. Everything else is working as advertised. Any thoughts?

Thanks in advance for your help.

JamesL




Theme © iAndrew 2016 - Forum software by © MyBB