Jump to content


Add an External URL on ADD_ACTION

add_action

  • Please log in to reply
4 replies to this topic

#1 jdaganzo

jdaganzo

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 06 December 2013 - 12:09 PM

I am fairly new to Grocery Crud and I have read the documentation and searched the forum but I am looking to see how I can add an External URL instead of a link to another crud model within my application.  Here is my example:

 

    public function participant()
    {
      $crud = new grocery_CRUD();
      $crud->set_theme('datatables');
      $crud->set_table('participant');
      $crud->where('participant.EVENT_ID',1011);
      $crud->display_as('EVENT_ID','Event');
      $crud->display_as('DIVISION_ID','Division');
      $crud->set_relation('DIVISION_ID','division','{DIVISION_NAME}');
     $crud->set_relation('EVENT_ID','event','{EVENT_NAME}');
     $crud->add_action('Score', '', 'demo/action_more','ui-icon-plus',array($this,'score_participant'));

    }

 

    public function score_participant($primary_key , $row)
     {
        return redirect("http://www.example.com/add_score.php");
     }
 
 
When the PARTICIPANT model renders it wants to immediately redirect to my redirect page. I want to be a link that is external that I will eventually pass the row parameters to a custom external php page.  I have also tried to use SITE_URL, but that doesn't work cause it tries to build the base url for grocery crud with expecting it to go through the controllers.  Can someone give me a tip on how to make it go to a custom non grocery crud link and pass some values of the row to it?  
 
JD

 



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 06 December 2013 - 12:59 PM

Hi jdaganzo

 

There is an option i will suggest / recoment ...

$crud->unset_add() //...

this will remove the add button ....

After that's done - in the view ... add your own add button and make it point anywhere you want.. (before / after the echo $output)

 

Happy GCing :)



#3 jdaganzo

jdaganzo

    Newbie

  • Members
  • Pip
  • 8 posts

Posted 06 December 2013 - 02:41 PM

 Amit....thanks for you reply but the goal is to not just remove the ADD  button and replace it with a random external link.  The goal is to keep an action button within the datagrid and when clicked have it call a non GC object (i.e. add_score.php) but also pass some of the values within that row to the external url.  Attached is a better example (it's a screenshot of what i am trying to accomplish):

 

http://screencast.com/t/d3m4d1Mq8r



#4 jinbatsu

jinbatsu

    Member

  • Members
  • PipPip
  • 23 posts

Posted 15 December 2013 - 03:32 PM

Hello @jdaganzo,

Why do you you use redirect? User still need click to choose which row to view right?

 

do you mean like this?

public function score_participant($primary_key , $row) {
	return 'http://www.example.com/add_score.php?pid_id=' . $row->PID_ID . '&event_id=' . $row->EVENT_ID);
}

change variable name to suite your need.

 

----

EDIT:

Well, you post double thread with the same topic question, with this one.

And web-johnny already answered here.



#5 testntrial

testntrial

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 24 September 2018 - 12:38 AM

Hello All GC users

 

Thanks John Skoumbourdis for this wonderfull system.

 

I was facing issue of changing add link to my custom form. Search on GC forum lead me to this page where the last response was in Dec 2013.

Most of the solutions were referring to add_action which creates new link in Action coulmn.

 

This is very late as I was just trying GC now and had the same issue of changing Add action for some requirements by passing custom url.

I could achieve this by some modifications in GC library and at the end just by using: $output = $crud->render($new_create_url);

 

One can get the desired function link from controller at the same place in list top with new custom url link.

 

To achieve this Just pass the same varible in all places in the GC file from render function down to line arond 3308 where there is protected function state_url($url = '', $is_list_page = false).

Change the function signature like protected function state_url($url = '', $is_list_page = false,$custom_add_url='').

In this function at line 3338 - $state_url =  site_url(implode('/',$state_url_array).'/'.$url);

add condition like:

if($url == 'add' and $custom_add_url !='' or $custom_add_url != null)

{
    $state_url = $custom_add_url;//substr(site_url(implode('/',$state_url_array)), 0, -6) . '/create_khutbah';
 }else{
    $state_url =  site_url(implode('/',$state_url_array).'/'.$url);              
 }

 

May be some one has better solution.

 

This is purely for people to love GroceryCrud.

Hope this helps some one out there in this world.

 

Best Luck







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users