I am still learning about user defined tags, but I still don't know how to do things.
I have a table, in the same DB as my CMSMS install, called users, with fields , ID / firstname / surname / country
eg.
ID / firstname / surname / country
1 / paul / connors / ireland
2 / mary / martin/ england
3 / jack / hurley / ireland
4 / sean / jones / ireland
And now I want to display the table data on say a page called "ireland" but I only want to list the users who have ireland as their country code.
Some questions:
1) as it's a new table do I have to do another DB connect ?
2) Can I pass a content block details to the UDT ? as in one content block is titled country, and if I put in ireland on that content page it will only show people with ireland property
3) can I parse GET variables, as in if I wanted to do pagnation of pages that will have too many entries ? as in specify a start paramater ?
Any ideas ?
example of displaying another table's content in the same DB
Re: example of displaying another table's content in the same DB
1. Use the same connection to DB as long it is the sane one used for CMSms.
3. UDT is php script without opening and closing tagas ("") so yes you can access $_GET variable from UDT. Also you can access it with smarty http://www.smarty.net/manual/en/languag ... smarty.php and pass it to your UDT
2.
This is UDT i use to "make a good guess" what response id would be while form has not been sent yet.
Usage
a. In your case use tag "{get_template_vars}" to see available vars in particular page.
b. Create another parameter to tag (e.g. $params['country'])
c. Add "WHERE" close to query with received value from country parameter.
Good ADOdb manual can by found here http://phplens.com/lens/adodb/docs-adodb.htm
3. UDT is php script without opening and closing tagas ("") so yes you can access $_GET variable from UDT. Also you can access it with smarty http://www.smarty.net/manual/en/languag ... smarty.php and pass it to your UDT
2.
This is UDT i use to "make a good guess" what response id would be while form has not been sent yet.
Code: Select all
/*$params['assign']*/ /*variable name to assign resp_id value to*/
global $gCms;
$db = $gCms->GetDb();
$query = 'SELECT id FROM `'.cms_db_prefix().'module_fb_resp_seq`';
$dbresult = $db->Execute($query);
$assign = FALSE;
if ($dbresult && ($row = $dbresult->FetchRow())){
$assign = (int)$row['id'];
$assign = $assign +1 ;
$assign = (string)$assign;
if (!empty($params['assign'])){
$gCms->smarty->assign($params['assign'], $assign);
}
}
return;
Code: Select all
{get_next_response_id assign='test_var'}
{$test_var}
b. Create another parameter to tag (e.g. $params['country'])
c. Add "WHERE" close to query with received value from country parameter.
Good ADOdb manual can by found here http://phplens.com/lens/adodb/docs-adodb.htm
Re: example of displaying another table's content in the same DB
Thanks Peciura for your help in this, I went with the PHP method in the end, as might want to use the code elsewhere.
Sorry for the delay in thanking you !
Paulie
Sorry for the delay in thanking you !
Paulie
my site : Dublin insider tips