I'm trying to create a UDT that makes use of the CreateFrontEndLink method to create monthly archive links on a sidebar, sorta like:
Archive
May 2011
March 2011
Feb 2011
<etc>
It does a quick scan of the database and creates links to the starting point of each month's CGBlog entries. It works fine, but I have to hard-code '$id' that CreateFrontEndLink requires. When clicking on the 'next' link, I see that my $id is 'm9efca', which I set $id to in my UDT. If I set it to a more normal 'cntnt01' it doesn't work right.
What is the purpose of $id and how does one dynamically assign it? I know that $id is provided when a module is instantiated, but I don't know how to use this in a UDT. I'm usually pretty good with looking at the code to solve my issues, but this one escapes me, probably because $id is too generic of a variable name and I get too many hits when searching.
Link to the site (in development): http://theboutiquebusiness.com/index.php?page=home
Question regarding module $id
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Question regarding module $id
The 'id' identifies the module call or tag that will process the event on the resulting side.
So if you have (in your page or template)
{Module1}
{Module2}
{Module1 action='again'}
When the call to {Module1 action='again'} generates a form, and the user clicks 'submit' that same call to the module will 'handle' the form (so that parameters, and state information matches up). The special id 'cntnt01' indicates that the {content} block will handle the resulting code.
IF your form or actions are redirecting to a different page, OR you have your module calls within the {content} block then the only real solution is to use the 'cntnt01' id
So if you have (in your page or template)
{Module1}
{Module2}
{Module1 action='again'}
When the call to {Module1 action='again'} generates a form, and the user clicks 'submit' that same call to the module will 'handle' the form (so that parameters, and state information matches up). The special id 'cntnt01' indicates that the {content} block will handle the resulting code.
IF your form or actions are redirecting to a different page, OR you have your module calls within the {content} block then the only real solution is to use the 'cntnt01' id
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.
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.
Re: Question regarding module $id
For what I know, cntnt01 makes the module replace the entire {content} tag with its output
With the module $id you get the 'inline' behaviour, where the module just replaces the module tag. In this case CMSms needs to know which tag asked for the new content, because there can be more tags for the same module on one page (template/content). That's where the module id comes in.
edit:
too late

With the module $id you get the 'inline' behaviour, where the module just replaces the module tag. In this case CMSms needs to know which tag asked for the new content, because there can be more tags for the same module on one page (template/content). That's where the module id comes in.
edit:
too late


Re: Question regarding module $id
Thanks for the info.. I'll have to digest this a bit and see how I can use this to solve my UDT question. 

Re: Question regarding module $id
OK.. I think I understand what's going on.. Setting the $id to 'cntnt01' wasn't honoring the 'number' argument being passed {CGBlog number=2} because the entire {content} tag is being replaced and the 'number=2' isn't being processed.
I got it to work with 'cntnt01' by adding 'number'=>2 in $params, but this isn't optimal, due to any params in the {CGBlog} call would need to be duplicated in $params in the UDT.
How is 'm9efca' generated? I'm assuming that part of it is a md5 hash, and if I change one letter, it doesn't work. Any way I can generate my own id value, so that the results can be processed by the {CGBlog} tag instead of completely replacing the {content} tag?
I got it to work with 'cntnt01' by adding 'number'=>2 in $params, but this isn't optimal, due to any params in the {CGBlog} call would need to be duplicated in $params in the UDT.
How is 'm9efca' generated? I'm assuming that part of it is a md5 hash, and if I change one letter, it doesn't work. Any way I can generate my own id value, so that the results can be processed by the {CGBlog} tag instead of completely replacing the {content} tag?
Re: Question regarding module $id
Interesting... A Google search of 'm9efca' lands me on a bunch of blogs where they set number=2.. so the $id generated has something to do with the parameters passed to {CGBlog}.. Not sure how this helps me yet, but it's a start. 
If {CGBlog} stores it's $id in a Smarty variable, or there is some way I can get it to store it (without modifying code), I should be able to pick this up in my UDT.. hmm.

If {CGBlog} stores it's $id in a Smarty variable, or there is some way I can get it to store it (without modifying code), I should be able to pick this up in my UDT.. hmm.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Question regarding module $id
every module derived from CGExtensions uses the smarty variable {$actionid} when the action is instantiated... that smarty variable is available and valid (till it's overwritten by another action).
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.
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.
Re: [SOLVED] Question regarding module $id
Ha! I found it! {get_template_vars} shows me that $actionid is set 'm9efca'.. I can capture it right after my {CGBlog} call and extract it in my UDT.
Of course this only works on pages where {CGBlog} is displayed, but I have an easy way around that
Thanks for bearing with me while I think out loud.
EDIT: Thanks, Calguy.. I figured it out just as you posted.
Of course this only works on pages where {CGBlog} is displayed, but I have an easy way around that
Thanks for bearing with me while I think out loud.

EDIT: Thanks, Calguy.. I figured it out just as you posted.
Re: Question regarding module $id
Silly me... I just discovered that CGBlog has an 'archive' action that does exactly what I want without all the runaround that I've been doing 
Well.. At least I learned something.

Well.. At least I learned something.
Re: Question regarding module $id
...except that the 'summarypage' option doesn't work when pretty URLs are turned on.. I'll file a bug report.