'action' argument of CreateFrontendLink seems to be ignored

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
bslorence

'action' argument of CreateFrontendLink seems to be ignored

Post by bslorence »

I'm trying to write a module and I have a page where a user can set one of the module's options by clicking on one of a list of GET-style links. I create the links like this:

Code: Select all

$page_url = $this->CreateFrontendLink($id, $return_id, 'process_choice', '',
                                      array('option' => $setting), '',
                                      true);
echo "<a href='".$page_url."'>[choice X]</a>\n";
And then I have a file action.process_choice.php in my module's directory, but the code in it is never executed. I've been digging through CMSMS's index.php and also looking at the FrontEndUsers code a bit, because it uses a similar mechanism for its "logout" link.

From what I can see, the 'action' passed to CreateFrontendLink is never automatically invoked, and the only reason that the FrontEndUsers "logout" link works is because I have a global content block with this Smarty tag in it:

Code: Select all

{cms_module module=FrontEndUsers}
So then when FrontEndUsers is invoked, its DoAction() somehow knows that the action required is 'logout'. Meanwhile, in my "set your option" page I have:

Code: Select all

{cms_module module=MyModule action='choose.php'}
So the 'process_choice' action never has the chance to run.

Is this the way things are meant to work? I was hoping that CMSMS would pass control to the "action" I specified in CreateFrontendLink(), before it rendered any content. For one thing, the action writes to a field in the database that one of my global content blocks reads from every time the page is loaded, so I was hoping to have that field updated before the global content block was rendered, so that the user's choice of option takes visible effect immediately.

But maybe I'm just not understanding the distinction between an "inline" link and a non-inline. Is this documented somewhere? If so, could someone point me to the documentation? If not, could someone kindly explain the difference to me?

When I set CreateFrontendLink()'s parameter "inline" to false, then action.process_choice.php is executed. It's still not executed before content is rendered, though, so my global content block still has the old value of the setting.

Is there some more straightforward way for me to achieve what I'm after? I.e., for the user's choice to be processed before the main content area of the page is rendered?

Thanks, Ben
Last edited by bslorence on Wed Apr 25, 2007 12:43 pm, edited 1 time in total.
Post Reply

Return to “Developers Discussion”