Jump to content


how to integrate auth library & G.Crud together and two or more field in one row?

crud usermanagement user based crud

  • Please log in to reply
5 replies to this topic

#1 likhon3k

likhon3k

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 01 February 2013 - 10:35 AM

Hello Guys...
It's me Likhon, New in this library and this forum also.

I am totally pleased to get grocery crud library. its really very good to programmer and its taking less time to build up an application. I am trying to working with.

I am facing some problem:

1) I am unable to show two or more input field in a row on add page. Grocery Crud build every database field on individual row. I want to show input filed in add/edit form like this:

Row 1: First Name, Middle Name, Last Name
Row 2: Age, Gender .....
etc.

2) I can use grocery crud and auth library. But I want to integrate both like CMS. data/article will be inserted by user name wise in a single table.

suppose: User: A, B, C in my user list. now whoever login and insert data then automatically inserted his name also.
Posted Image

here user likhon login to application. I want to add this username will be automatically inserted into table list and same as other user.

Posted Image

when user A will login and insert article/post/data then its name automatically need to inserted into database
when user B will login and insert same thing, its name automatically inserted into database.

like Joomla/Wordpress user based article management.

Posted Image

I searched more in this forum but unable to find this solution. If any one posted it before than sorry but please give me the solution link.

Please give me a good solution.

#2 likhon3k

likhon3k

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 01 February 2013 - 04:11 PM

.....

2) I can use grocery crud and auth library. But I want to integrate both like CMS. data/article will be inserted by user name wise in a single table.

suppose: User: A, B, C in my user list. now whoever login and insert data then automatically inserted his name also.
Posted Image

here user likhon login to application. I want to add this username will be automatically inserted into table list and same as other user.

Posted Image

when user A will login and insert article/post/data then its name automatically need to inserted into database
when user B will login and insert same thing, its name automatically inserted into database.

like Joomla/Wordpress user based article management.

Posted Image

I searched more in this forum but unable to find this solution. If any one posted it before than sorry but please give me the solution link.

Please give me a good solution.

--------

I think i solved it now. but not sure completely, trying from last few hours but now its done. but if I am wrong this way then please tell me the right way. I am using codeigniter session procedure with grocery crud library. I am not using auth library here.

solution:

1. $crud->callback_after_insert(array($this, 'log_user_after_insert')); // using this code in main function like article function at controller

2. function log_user_after_insert($post_array,$primary_key)
{
$data=$this->session->all_userdata(); // this will take session username and data.
$username=$data['username']; // i wanted to insert username beside of article

$user_logs_insert = array(

"username" => $username,

);

$this->db->where('id', $primary_key); // compare articles id = article id

$this->db->update('articles',$user_logs_insert); // inserting username into article table by update function

return true;
}


3. create a field on article table by username (if you want to insert username), user_id if you want to insert user_id

5. $crud->unset_fields('username'); add this into article table. it invisible username field form add form.


----

Problem 1 not solved yet. If any one know can share it plz.

#3 likhon3k

likhon3k

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 08 February 2013 - 06:18 PM

Victor, I am sorry that I am unable to find out the solution and that is why I am asking here again.

 

How can I show two or more input field in a single row.

 

like row 1: first name, middle name, last name.

 

row2: age, location etc.

 

I found few post but it was not clear to me.



#4 davidoster

davidoster

    Grocery CRUD Ninja

  • Advanced Member
  • PipPipPip
  • 1,068 posts
  • LocationAthens, Greece

Posted 09 February 2013 - 12:57 AM

With number 1 I can't help you because I haven't done it, but as a quick tip, all the input fields have a unique id. You can use this to alter the display either via javascript or css.

Number 2. Well what you are asking to be honest has nothing to do with grocery crud library!!!

It has to do with CodeIgniter integrating with auth library! If you search on the web for this you'll find many examples how this can be done!!!

I suggest you look here first: http://benedmunds.com/ion_auth/


____________________________________________________________

 

rtfm_small.jpg---!!!Please read these guidelines before asking to the forums!!!---

____________________________________________________________

 

David Oster aka George Pasparakis,
http://odphotography.com
http://eletter.gr


#5 likhon3k

likhon3k

    Advanced Member

  • Members
  • PipPipPip
  • 56 posts

Posted 10 February 2013 - 03:46 PM

With number 1 I can't help you because I haven't done it, but as a quick tip, all the input fields have a unique id. You can use this to alter the display either via javascript or css.

Number 2. Well what you are asking to be honest has nothing to do with grocery crud library!!!

It has to do with CodeIgniter integrating with auth library! If you search on the web for this you'll find many examples how this can be done!!!

I suggest you look here first: http://benedmunds.com/ion_auth/

 

Thanks. I solved problem 2 by custom controller.

 

But now I am in problem with 1. If you can then please inform me.

 

Thanks in advance...



#6 mnish

mnish

    Member

  • Members
  • PipPip
  • 23 posts
  • LocationIndia

Posted 03 September 2013 - 06:07 PM

for this purpose you have to create a separate theme. I am giving some suggestion but if I am wrong this way then please tell me the right way.

 

we take default theme ok.

 

1. copy your default theme folder and create a copy.

 

2. rename it i.e. custom.

 

3. open file add and edit.php from view folder

 

in add.php

 

<?php
            $counter = 0;
                foreach($fields as $field)
                {
                    $even_odd = $counter % 2 == 0 ? 'odd' : 'even';
                    $counter++;
            ?>
            <div class='form-field-box <?php echo $even_odd?>' id="<?php echo $field->field_name; ?>_field_box">
                <div class='form-display-as-box' id="<?php echo $field->field_name; ?>_display_as_box">
                    <?php echo $input_fields[$field->field_name]->display_as?><?php echo ($input_fields[$field->field_name]->required)? "<span class='required'>*</span> " : ""?> :
                </div>
                <div class='form-input-box' id="<?php echo $field->field_name; ?>_input_box">
                    <?php echo $input_fields[$field->field_name]->input?>
                </div>
                <div class='clear'></div>    
            </div>

 <?php }?>

 

change this according to your field name like

 

<?php

          foreach($fields as $field)
                {

?>

 

<?php if($field_name == 'first_name' || $field_name == 'middle_name' || $field_name == 'last_name') {  ?>

 

    <div>

<?php echo $input_fields[$field->field_name]->input ?>

 

</div>

 

<?php } ?>

 

<?php } ?>

 

it shows three field in a single row. You can also add some attribute like placeholder etc.







Also tagged with one or more of these keywords: crud, usermanagement, user based crud

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users