Page 1 of 1

Using a tag value as another tag's parameter

Posted: Tue Feb 02, 2010 4:07 pm
by rlparker25
I have a UDT that creates a list of values, e.g. a,b,c,d,  that I need to pass to a parameter of another tag.

I have the following code in my template


{capture assign='tmpymabii'}{getYMABII}{/capture}

{content block="ymabii1" type="dropdown" label="ymabii1" page_tab="main" items=$tmpymabii assign='ymabiiblock1'}

if I just output {$tmpymabii} then it writes my list to the page but if I try to pass it to the items param it doesn't put anything in there.

I need to be able to dynamically create the list of options to be passed through to the dropdown box. Is there any other way I can pass my values to a param?

thanks

Re: Using a tag value as another tag's parameter

Posted: Tue Feb 02, 2010 4:29 pm
by vilkis
Hi,
It is simple. In first UDT (getYMABII) use the following code:

Code: Select all

global $gCms;
$smarty =& $gCms->GetSmarty();
$smarty->assign('tmpymabii', $YOUR_ARRAY_VARIABLE);
Then you need  only (no capture)

Code: Select all

{getYMABII} 
{content block="ymabii1" type="dropdown" label="ymabii1" page_tab="main" items=$tmpymabii assign='ymabiiblock1'}
vilkis

Re: Using a tag value as another tag's parameter

Posted: Tue Feb 02, 2010 4:45 pm
by rlparker25
hi, that doesn't work either!

my UDT is

Code: Select all

global $gCms;

$db = &$gCms->db;

$smarty =& $gCms->getSmarty();
$page_alias = $smarty->get_template_vars('page_alias');

$myquery = "SELECT * FROM YMABII WHERE published = 'Published' ORDER BY name ASC";
	$myresult = $db->Execute( $myquery );
	
	
	
	$ymabiiarray = ' Please Select##Please Select';
while ($myresult && $row = $myresult->FetchRow())
{
 	
	$ymabiiarray .=  ','.$row['id'].'##'.$row['name'];
	
}	
	$smarty->assign('ymabiiarray', $ymabiiarray);
and then I have

{getYMABII}

{content block="ymabii1" type="dropdown" label="ymabii1" page_tab="main" items=$ymabiiarray assign='ymabiiblock1'}

in my template

Re: Using a tag value as another tag's parameter

Posted: Tue Feb 02, 2010 5:47 pm
by JeremyBASS
Best to read here... http://forum.cmsmadesimple.org/index.ph ... #msg192498

There is no processing on the page editing area... so $ymabiiarray  of

{content block="ymabii1" type="dropdown" label="ymabii1" page_tab="main" items=$ymabiiarray assign='ymabiiblock1'}

wouldn't work... but as you'll read I have solved this issue...

HTH Cheers
jeremyBass

Re: Using a tag value as another tag's parameter

Posted: Wed Feb 03, 2010 12:18 pm
by rlparker25
hi, thanks for that but when I try your versions of content and function.content it breaks my site. I'm guessing that's because your code is for 1.6 and my site is 1.5?

Do you know what changes I would need to make to get it to do the dynamic params bit in the code for the older version? is it just a couple of functions I would need to change or the whole thing?

Thank you

Rachael

Re: Using a tag value as another tag's parameter

Posted: Wed Feb 03, 2010 2:59 pm
by JeremyBASS
Just upgrade... upgrading is simple and you can jump up to 1.6.6 in about 15 mins... besides you need to do that to get support if something goes wrong... but don't forget to back up... Cheers -J

Re: Using a tag value as another tag's parameter

Posted: Wed Feb 10, 2010 10:46 am
by rlparker25
Hi, I upgraded my site and tried your content type files. It adds the dynamic drop downs perfectly however the normal page content no longer shows on my site! So now I have the drop downs working in my admin area but no text on any of my pages

any ideas what I have done?

thanks