• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeExtinguisher 2.0 Release Candidate 14.2

[eluser]Paul T[/eluser]
Thanks for the help, jTaby and Palino!

What I'm ultimately trying to accomplish is to filter results on the overview page, by a related field.

Using the access_restriction only applies to the relational container in the "add new" form.

For example, let's say I have three tables--departments, staff, departments_staff

On the Staff Overview page, I am showing the departments that a staff is a member of. My client wants to be able to use the search bar to filter by departments on that page, so only staff that are members of the search result are listed.

But if I try to do that, I get a database error because Codex doesn't know that the department is from a different table -- it's looking in the staff table.

Is this a limitation of this version, or am I doing something wrong? If searching that field is not allowed, that field should not be an option in the search field dropdown menu.

Anyway, if I'm missing something here, please let me know what it is. If this is not part of Codex, how would I go about adding in this functionality?

~Paul

[eluser]unsub[/eluser]
hey, jTaby,

epoch?

Tongue wow, learn something new every day! honestly, I didn't really know anything about that 'till I searched it.

cheers

[eluser]Paul T[/eluser]
OK, after spending some time dissecting the code, I came up with a decent solution. I'm not sure how scalable it is, but it gets the job done.

First, in codexcontroller, around line 280:

Code:
foreach($field_names as $k=>$v)
        {
            $field_names[$k] = $this->table . '.' . $v;
        }

I did this because there may or may not be a join statement, but if there is, this will prevent ambiguity.

In my controller, I added a couple new arrays to the config array. One maps the many-to-many field name from 'display_fields' to the proper SQL syntax. The other array contains whatever joins you will need. For example:

Code:
$config = array(
                    'db_table' => 'yourTable', //The name of the table associated with this controller
                    'form_setup' => $this->spyc->YAMLLOAD($this->codexadmin->getDefinitionFileName('yourTable_form')), //The array that holds our elements
                    'controller_name' => 'yourController', //The name of the controller, so that it can be used when generating the URLs
                    'primary_key' => 'id', //The name of the controller, so that it can be used when generating the URLs
                    'display_fields'=>array('yourTableField1','yourTableField2','yourRelatedField1'),
                    'field_to_lookup'=>array('yourRelatedField1'=>'yourRelatedTable.yourRelatedFieldName'),
                    'table_joins'=>array('yourJoinTable'=>'whatever = whatever','yourJoinTable2'=>'whatever = whatever'), //for use in $this->db->join()
                    'rules'=>$rules
                    );

Then, in the codexcontroller, make sure to declare your table_joins and field_to_lookup variables, and also populate those variables in the setConfig() function.

In the search() function, I replaced this code:

Code:
for($i=0;$i<count($keywords);$i++){
            $this->db->like($fields[$i],$keywords[$i]);
        }

with this code:

Code:
for($i=0;$i<count($keywords);$i++){
            
                $lookup = $fields[$i];
                if(count($this->field_to_lookup) > 0 && $this->field_to_lookup != '' && array_key_exists($fields[$i], $this->field_to_lookup))
                {
                    if ($keywords[$i] != '')
                    {
                        $this->db->like($this->field_to_lookup[$lookup],$keywords[$i]);
                        $includejoinstatement = 'yes';
                    }
                }
                else
                {
                    $this->db->like($this->table.'.'.$fields[$i],$keywords[$i]);
                }
    }
    
        if(isset($includejoinstatement)) {
            foreach($this->table_joins as $field=>$value)
                $this->db->join($field,$value);
    }


Did I write nice PHP? Nope. Did I put all this modified code in the right places? Probably not. Does it work? So far!

I'm sure many of you will find a much more elegant way to approach this. If you do have a better way, please share it so I can use well formed code, and not my sloppy PHP. :-)

~Paul

[eluser]dbelanger[/eluser]
Hello,

Using the current version of CodeExtinguisher and having a lot of problems putting a wysiwyg interface on my text areas. I was using tinymce but for some reason the toolbar no longer appears above the textarea but at the top of the page. It was fine before but now I can't get it to be in the proper place.

Any suggestions on a good wysiwyg to use?

Thanks

[eluser]Paul T[/eluser]
[quote author="dbelanger" date="1217666678"]Hello,

Using the current version of CodeExtinguisher and having a lot of problems putting a wysiwyg interface on my text areas. I was using tinymce but for some reason the toolbar no longer appears above the textarea but at the top of the page. It was fine before but now I can't get it to be in the proper place.

Any suggestions on a good wysiwyg to use?

Thanks[/quote]

The wysiwyg is working fine for me.

Code:
description:
    class: Editor
    label: Description
    attributes:
        rows:10
        cols:100
    params:
        options:
            theme: advanced
            plugins: fullscreen,paste,spellchecker
            theme_advanced_toolbar_location: top
            theme_advanced_toolbar_align: left
            theme_advanced_buttons1_add: |,forecolor,fullscreen
            spellchecker_languages : "+English=en"

Also, be sure to use jTaby's update for the Editor plugin, located here.

Hope that helps,
Paul

[eluser]matthewr[/eluser]
Is this project dead? The site is extremely outdated and questions haven't been answered lately.

Anyway, I sure hope it's not, i developed a client project using this system. Anybody know how to specify list_text and list_header in the YAML file?

[eluser]Paul T[/eluser]
[quote author="matthewr" date="1217932341"]Is this project dead? The site is extremely outdated and questions haven't been answered lately.

Anyway, I sure hope it's not, i developed a client project using this system. Anybody know how to specify list_text and list_header in the YAML file?[/quote]

According to jTaby, he's taking a break from coding for awhile. He's got a shell for an updated website, with forums and everything. Should be nice. Hopefully his break will revitalize the Codex effort. It's a great project but still needs lots of development and documentation. But even in its current state, it's still very usable, and a tremendous time-saver.

But I wonder how many people are using it, and what modifications they have made to it that could turn into contributions? There's probably a ton of forks by now, it would be nice to bring everything back together in some form or another.

As far as list_text and list_header, sorry, haven't come across that yet.

[eluser]webberoo[/eluser]
This all looks really cool! I just wish I had the knowledge to use it. Can't seem to be able to make pages.
Heres what I did:
1. Followed Install made sure everything works -- it does great!
2. I added a new table to db and propagated it with some data -- it appears in menu with forms and everything YA!
3. Attempted to create a YML file called news.yml (relates to news table) with 2 fields like
Code:
form_setup:
    title:
        class: TextBox
    text:
        class: TextArea
4. That seemed to work so I got a bit more adventurous and added this
Code:
form_setup:
    title:
        class: TextBox
    text:
        class: TextArea
    live:
        class: RadioGroup
        params:
             list:
                 1: y
                 2: n
doh! I get this error
Quote:Fatal error: Cannot use string offset as an array in C:\Documents and Settings\Tobz\Desktop\websites\Admin4AFBJJ\SITE4\codex\application\libraries\spyc.php(511) : eval()'d code on line 1

5. So I try creating a page. I copy the example page and change all the example parts to news, also changing my news.yml to news_form.yml. I commented out the ruleset in both places and went to url "backend.php/news"

DOH! same error.

I guess its cause I've never used YAML and I have no doc's to look at.

I understand you're feelin the burn. I know your pain buddy. Confusedhut:

So I'll check back next project and see how your doing. I'd offer my help but I'm to noob :down:

If anyone can shed some light on where I'm going wrong to help me understand this I will document out ALL plugins as I discover them.

-webberoo

[eluser]webberoo[/eluser]
WooHoo!

I discovered the fix by playing around with the database and the edit form.
Heres what I discovered about the RadioGroup Plugin:

Code:
form_setup
    live: //the name field in db table
        class: RadioGroup //the plugin to call
        params: //call the parameters for class
            list: //create array of radio buttons
                1: Its Live //create each button example below
                2: Its not live //value in db: label on form

If you get the horrible "php error undefined index". It probably means that you have your "value: label"
set wrong.

[eluser]webberoo[/eluser]
[quote author="matthewr" date="1217932341"] Anybody know how to specify list_text and list_header in the YAML file?[/quote]

Have you tried adding the following parameter "display_name: list header" you can add it like this
Code:
params:
    diplay_name: name to be displayed


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.