How do I use $this->CreateLink

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
marshy

How do I use $this->CreateLink

Post 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.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: How do I use $this->CreateLink

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
webmastertgp
New Member
New Member
Posts: 4
Joined: Sun Dec 21, 2008 6:11 am

Re: How do I use $this->CreateLink

Post 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...
Post Reply

Return to “Developers Discussion”