Page 1 of 1

Creating a user defined tag related to a module.

Posted: Sat Jan 16, 2010 5:50 am
by Salketer
Hi everyone,

I would like to define a tag to be able to create a link pointing to the specified page (using alias) and in that same tag I would need to retrieve some database information from a module I have created.

To put it more clearly, the access to the module's items is necessary so I can retrieve the correct id using the name of an item. The link created will not have to hold any information about the module itself, the module information will merely be used to display the appropriate text and to point at the correct anchor within the given page. I can figure out how the management of the link creation but I don't know how to grab an instance of the module to accomplish my needs.

I am not sure if I am clear enough, feel free to request more information as long as you specify what you'd like to know accurately.

Thank you very much for your time!

Re: Creating a user defined tag related to a module.

Posted: Sat Jan 16, 2010 6:17 am
by kittymcooper
Why not make one of the actions in your module the creation of this link? Then call your module with the parameters for the link.

Re: Creating a user defined tag related to a module.

Posted: Sat Jan 16, 2010 8:58 am
by Salketer
You are right, that part seemed so complex yet it is very simple... Something like {cms_module module="mymodule" page="thepage" item="itemalias"} would be pretty much all I need. Thanks

Now for the next part, how can I make my module create a valid link to the page requested by the param? Remember I want to pass the alias only.

thank you all!

Re: Creating a user defined tag related to a module.

Posted: Sat Jan 16, 2010 5:58 pm
by kittymcooper
If you have the content alias then the url
index.php?page=content_alias
(replace content_alias with actual one)
works fine, so maybe I misunderstand your question?

if all you have is the content id then ...
from the doc
http://wiki.cmsmadesimple.org/index.php/User_Handbook/Developers_Guide/Creating_Modules#Access_current_page_id_or_alias
   $hm =& $gCms->GetHierarchyManager();
    $curnode =& $hm->getNodeById($pageid);
    $curcontent =& $curnode->GetContent();
    echo $curcontent->GetURL();