[solved] Calling a module within a UDT or vice-versa
[solved] Calling a module within a UDT or vice-versa
I'm trying to use a UDT to grab the URL GET variables, and use them inside a module call.
So in effect I want something like this in a page:
{news start={udt_getstart} number={udt_getnumber} }
This doesn't work as the closing bracket for "udt_getstart" will close the News module call and the rest will be output as-is on the page. Is there another way to grab the page's URL parameters and use them in a module call?
Another thing I tried was grabbing the GET variables in a UDT, and then echo-ing out the module call to the page:
--
$start = $_GET['start'];
$number = $_GET['number'];
print '{news start='.$start.' number='.$number.' }';
--
But that just printed out a string and didn't actually call the module....
Any help would be appreciated.
So in effect I want something like this in a page:
{news start={udt_getstart} number={udt_getnumber} }
This doesn't work as the closing bracket for "udt_getstart" will close the News module call and the rest will be output as-is on the page. Is there another way to grab the page's URL parameters and use them in a module call?
Another thing I tried was grabbing the GET variables in a UDT, and then echo-ing out the module call to the page:
--
$start = $_GET['start'];
$number = $_GET['number'];
print '{news start='.$start.' number='.$number.' }';
--
But that just printed out a string and didn't actually call the module....
Any help would be appreciated.
Last edited by AlanY on Sun Jul 19, 2009 9:25 pm, edited 1 time in total.
Re: Calling a module within a UDT or vice-versa
I have a similar problem. Have you solved this? If so, how?
Re: Calling a module within a UDT or vice-versa
I think you're on the right track with this:
{news start=$start number=$number}
But don't print it to the page. Try:Another thing I tried was grabbing the GET variables in a UDT, and then echo-ing out the module call to the page:
--
$start = $_GET['start'];
$number = $_GET['number'];
print '{news start='.$start.' number='.$number.' }';
{news start=$start number=$number}
Re: Calling a module within a UDT or vice-versa
There are many solutions to this, among them is using Smarty's {assign} or {capture} functions or even accessing the news module directly (available in the global $gCms->modules['News']['object']).
Easiest would be to use the $_GET variables, available in the$smarty.get property:
Kind regards,
D
Easiest would be to use the $_GET variables, available in the$smarty.get property:
Code: Select all
{news start=$smarty.get.start number=$smarty.get.number}
D
Re: Calling a module within a UDT or vice-versa
read more about smarty capture
you can have a udt that generates anything like {getdata}
then you can use it like:
you can have a udt that generates anything like {getdata}
then you can use it like:
Code: Select all
{capture assign="getdata"}{getdata}{/capture}
{module var=$getdata}
Re: Calling a module within a UDT or vice-versa
I don't really understand any of this, as i'm just a designer. My UDT looks like this so far:
global $gCms;
$thispage = $gCms->variables['page_name'];
if ($thispage == "portfolio")
echo "Portfolio:"
{cms_module module='CGBlog' action='browsecat' summarypage='det_Portfolio'}
echo "";
elseif ($thispage == "divagacoes")
echo "Divagacoes:"
{cms_module module='news' action='browsecat' detailpage='det_Divagacoes'}
echo "";
elseif ($thispage == "contato") echo "etc";
else echo "default text";
But I get an error in line 5. The workaround is having a different template for each page, but I wanted to do this right...
global $gCms;
$thispage = $gCms->variables['page_name'];
if ($thispage == "portfolio")
echo "Portfolio:"
{cms_module module='CGBlog' action='browsecat' summarypage='det_Portfolio'}
echo "";
elseif ($thispage == "divagacoes")
echo "Divagacoes:"
{cms_module module='news' action='browsecat' detailpage='det_Divagacoes'}
echo "";
elseif ($thispage == "contato") echo "etc";
else echo "default text";
But I get an error in line 5. The workaround is having a different template for each page, but I wanted to do this right...
Re: Calling a module within a UDT or vice-versa
Try this in your template:atired wrote: I don't really understand any of this, as i'm just a designer. My UDT looks like this so far:
global $gCms;
$thispage = $gCms->variables['page_name'];
if ($thispage == "portfolio")
echo "Portfolio:"
{cms_module module='CGBlog' action='browsecat' summarypage='det_Portfolio'}
echo "";
elseif ($thispage == "divagacoes")
echo "Divagacoes:"
{cms_module module='news' action='browsecat' detailpage='det_Divagacoes'}
echo "";
elseif ($thispage == "contato") echo "etc";
else echo "default text";
But I get an error in line 5. The workaround is having a different template for each page, but I wanted to do this right...
Code: Select all
<div id='$gCms->parameters.page_name'>
<h4>{$gCms->parameters.page_name|ucfirst}:</h4>
{cms_module module='CGBlog' action='browsecat' summarypage="det_$gCms->parameters.page_name|ucfirst"}
</div>
Code: Select all
{if $gCms->parameters.page_name == 'portfolio'}
* this is only displayed on the portfolio page *
{/if}
D
Last edited by Anonymous on Fri Jul 17, 2009 2:31 am, edited 1 time in total.
Re: Calling a module within a UDT or vice-versa
UDT´s are for PHP code only
Templates, pages and content blocks are SMARTY and html
Regards
G
Templates, pages and content blocks are SMARTY and html
Regards
G
Re: Calling a module within a UDT or vice-versa
Ok, but smarty is waaay out of my league.
Dee pointed me the way to go, I think. But I tried placing this in my template, and nothing is displayed:
{if $gCms->parameters.page_name == 'portfolio'}
* this is only displayed on the portfolio page *
{elseif $gCms->parameters.page_name == 'divagacoes'}
*page specific content*
{/if}
Is page_name the page alias?
Dee pointed me the way to go, I think. But I tried placing this in my template, and nothing is displayed:
{if $gCms->parameters.page_name == 'portfolio'}
* this is only displayed on the portfolio page *
{elseif $gCms->parameters.page_name == 'divagacoes'}
*page specific content*
{/if}
Is page_name the page alias?
Re: Calling a module within a UDT or vice-versa
If you're a designer and not a programmer, Smarty should be more in your league than PHP code, although it has similar syntax and does need some getting used to. Luckily it has extended documentation.
page_name is the page alias indeed, it is displayed when you just use
The code you used should display "* this is only displayed on the portfolio page *" on the portfolio page and "* page specific content*" on the page with alias 'divagacoes':
If you're using it in a template I don't see why this wouldn't work. If you're trying to insert it on a page you'll have to turn off WYSIWYG because TinyMCE will change the -> into ->
Kind regards,
D
page_name is the page alias indeed, it is displayed when you just use
Code: Select all
{$gCms->parameters.page_name}
Code: Select all
{if $gCms->parameters.page_name == 'portfolio'}
* this is only displayed on the portfolio page *
{elseif $gCms->parameters.page_name == 'divagacoes'}
*page specific content*
{/if}
Kind regards,
D
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Calling a module within a UDT or vice-versa
{$page_alias}
nuf said.
nuf said.
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: Calling a module within a UDT or vice-versa
Thanks calguy,calguy1000 wrote: {$page_alias}
nuf said.
Some testing revealed $gCms->parameters is not always assigned.
I would have used {$gCms->variables.pageinfo->content_alias}, which does seem to be always available, but apparently a convenience variable {$page_alias} is assigned to Smarty as well.
Maybe some documentation about the variables assigned to Smarty would be a good thing... although it may have the devs realize too much is assigned right now. For example, I think not many users realize that anyone with rights to edit a page or template has access to the database user and password and thus can do any page operation he/she wants...
Kind regards,
D
Re: Calling a module within a UDT or vice-versa
When I replaced {if $gCms->parameters.page_name == 'portfolio'} with {if $page_alias == 'portfolio'} it worked. Thank you all.
Now I have a forum related question: I didn"t start this thread but it seems yhe person who did has abandoned it. Should I place the [SOLVED] tag?
Now I have a forum related question: I didn"t start this thread but it seems yhe person who did has abandoned it. Should I place the [SOLVED] tag?
Re: Calling a module within a UDT or vice-versa
Unless you started the thread, you can't edit the original post title, which is where [SOLVED] needs to go.