I searched for calguy1000's example as stated in other post but did not find it.
I use the news module to display pages generated by UDTs. (Kids parents, kids birthday, kids favorites, Kids siblings) I though it a rather clever idea. Now, I am trying out virtualmin, on another server, and virtualmin creates a single db for everything, so after moving I have to update a bunch of db connection names at the beginning of each UDT. Ideally I would insert a db UDT {mydatabaseconnection} at the start of each display UDT {kidsbirthdays} and so only have to update {mydatabaseconnection} if I switch db or username etc.
I have experimented with literals, links to scripts and looked for a db connect tag, but have so far been unsuccessful.
Thank you
call a udt from a udt (reuse a dbconnect user defined tag in a user defined tag)
Re: call a udt from a udt (reuse a dbconnect user defined tag in a user defined tag)
??jdwork wrote: I use the news module to display pages generated by UDTs.
Why you not use same DB connect of CMSMS (you have mysql data in config.php only)jdwork wrote: .... so after moving I have to update a bunch of db connection names at the beginning of each UDT.
Look in Documentation for Share your UDT for DB example
Alby
Re: call a udt from a udt (reuse a dbconnect user defined tag in a user defined tag)

Could it be as simple as:
Code: Select all
$dbconnect = mysql_connect($db_hostname,$db_username,$db_password);
. . .
mysql_select_db("studentdb", $con);
Maybe it'll also fix my error.
Code: Select all
cmsmadesimple string(61) "Smarty error: unable to read resource: "globalcontent:footer"" string(61) "Smarty error: unable to read resource: "globalcontent:footer""
I will get back to this later in the week.
Thanks Alby

Re: call a udt from a udt (reuse a dbconnect user defined tag in a user defined tag)
You can use something like
Code: Select all
global $gCms;
$db = &$gCms->db;
$query = "SELECT * FROM ".cms_db_prefix()."yourtablename WHERE category = ?";
$dbresult = $db->Execute($query, array($categoryid));
if( $dbresult )
{
while ($row = $dbresult->FetchRow())
{
...
}
}
else
{
echo 'DB error: '. $db->ErrorMsg().'<br/>';
}
Last edited by Jos on Mon Nov 09, 2009 10:45 am, edited 1 time in total.