Page 1 of 1

How do I use $this->CreateLink

Posted: Sat Mar 31, 2007 10:06 pm
by marshy
OK I know this is a dumb question so pls dont flame me.
But I have been messing with $this->CreateLink without much success.
Basically I have a module that extracts rows from a table, but it only pulls out 10 records at a time.
I want to create a link which passes a param (such as 'record'=>'10') that shows the next 10, and so on.
How do I do this.  Whenever I have tried CreateLink it goes to a blank page.
This is what I'm trying:

Code: Select all

$parameters = Array('record'=>'10');
echo $this->CreateLink($id, $action, $returnid, 'Show next 10 records', $parameters );
I want it to reload the current page but with my new param so I can use it in my SQL.
Could someone explain how exactly CreateLink is used and what all the function parameters do, such as $id, $returnid?

Cheers.

Re: How do I use $this->CreateLink

Posted: Sat Mar 31, 2007 11:07 pm
by calguy1000
That's the correct syntax for CreateLink in a module.  However, don't hold your breath that $action is a valid variable.  but $params['action'] should work.

Also: $id is an identifier used to identify a specific instance of a module (incase you call different modules on a page, this variable is used to identify that instance)... well, that's the best explanation I have for it anyways.

$returnid is the page id of the page to point to..... and it usually is the originating page, but can be changed (we change it for the detailpage parameter in News and a few other modules).

it's usually:
  $parameters = array( 'start_element' => $start_element,
                                      'page_limit' => $page_limit  ); 
  $this->CreateLink( $id, $params['action'], $returnid, $this->Lang('text_for_link'), $parameters );

I do this exact pagination stuff in the questions module, so you should be able to take a look at that and see that I'm doing exactly this stuff.

If you have any more questions, give me a shout.

Re: How do I use $this->CreateLink

Posted: Mon Dec 22, 2008 7:20 pm
by webmastertgp
Hi calguy1000, how to do almost the same thing but I want to make a link to another action of some module??? (not the default action and not in the admin section.)

please help me...