
Michael Mikkelsen
|
| Posted: 08/29/2005, 12:40 PM |
|
What code modifications would I need to make to allow for multiple BEGIN Row, END Row tags within a Grid. Currently if you add two more sets of BEGIN Row, END Row tags, Whatever is in the third set of tags is repeated 3 times. Would I need to modify the Grid class, the Template Class, both. I know this is a very complicated question and some have asked for similar on the wishlist but I am willing to rewrite 90% of the Grid Class if that is what is takes. Just give me a little direction of where to start and what would be a good way of doing it.
Thanks,
Michael Mikkelsen
|
|
|
 |
DonB
|
| Posted: 08/29/2005, 5:38 PM |
|
I'm having a hard time figuring out what you think would be the correct
behavior of such an arrangement. The idea of the 'row' block is that it's
repeated for every row of the data source.
What benefit are you hoping to get from having several row blocks? Are you
perhaps trying to produce grouped or 'table-within-table' types of output?
If so, so XML processing might be the solution, as you can probably express
the desired output in terms of an XSL transformation. This, of course, is
not native to CCS but is easily achieved (well, whether it is 'easy' is
dependent on how well versed you are in XML and XSLT)
--
DonB
http://www.gotodon.com/ccbth
<MichaelMikkelsen@forum.codecharge (Michael Mikkelsen)> wrote in message
news:5431364bff3087@news.codecharge.com...
> What code modifications would I need to make to allow for multiple BEGIN
Row,
> END Row tags within a Grid. Currently if you add two more sets of BEGIN
Row,
> END Row tags, Whatever is in the third set of tags is repeated 3 times.
Would
> I need to modify the Grid class, the Template Class, both. I know this is
a
> very complicated question and some have asked for similar on the wishlist
but I
> am willing to rewrite 90% of the Grid Class if that is what is takes.
Just give
> me a little direction of where to start and what would be a good way of
doing
> it.
>
> Thanks,
>
> Michael Mikkelsen
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
>
|
|
|
 |
Michael Mikkelsen
|
| Posted: 08/30/2005, 7:37 AM |
|
The first 'row' block would be repeated for each record, then the second 'row' block would be repeated for each record.
This means you could output one field for each record, then output the next field for each record, then the next field for eachrecord, and so on.
The most common use is:
Record# 1 2 3 4 5
Name Linda John Mike Brian Ken
Phone# 236 264 248 225 235
I am going to be outputing to an XML document that will be read by another program so it must be in a specific format.
|
|
|
 |
DonB
|
| Posted: 08/30/2005, 7:46 PM |
|
What you have is essentially:
SELECT name from sometable WHERE something=somevalue
UNION
SELECT phone from sometable WHERE something=somevalue
So I suppose you could make that the data source (switching to SQL instead
of Table as the data source type)
otherwise, since you say it goes into XML anyway, would be to go the XSLT
route and transform the columns into rows.
--
DonB
http://www.gotodon.com/ccbth
|
|
|
 |
feha
Posts: 712
|
| Posted: 08/31/2005, 12:54 PM |
|
I don't understand why would you like to use html template for this when you could do custom function to export or produce XML doument from DB ?
I use custom function to produce and generate RSS NEWS feed ( XML file) from DB.
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
Michael Mikkelsen
|
| Posted: 09/01/2005, 4:28 PM |
|
That is a very good idea. There is an example of generating the XML file from the database here: http://msdn.microsoft.com/library/default.asp?url=/libr...excelsqlxml.asp
After looking at the example I thought it would be easier to create the XML template and then use php/ccs to export the data/grid into the template. I already have the Excel/XML template and I want to be able to easily update it.
I was able to get my grid to display the way I want it to by adding labels for each column to the row like so.
<td>{mstr_recno}{mstr_recno0} </td>
<td class="">{mstr_recno1}</td>
<td class="">{mstr_recno2}</td>
<td class="">{mstr_recno3}</td>
<td class="">{mstr_recno4}</td>
<td class="">{mstr_recno5}</td>
I did this for each field that I was wanting to show. Only the first label pulls the data from the DB. The others are just blank labels that are set in the before show row event.
I only want to display up to 6 records.
My BeforeShowRow Event looks like this:
$fields = array("nameofprop", "mstr_recno", "addr_no", "addr_dir", "addr_name", "addr_str", "city", "county", "state", "saledate", "saleprice", "grbldgarea");
foreach ($fields as $field) {
eval("if (\$ec_tr_sl_ec_addrs->".$field.$rownum.") \$ec_tr_sl_ec_addrs->".$field.$rownum."->SetValue(\$ec_tr_sl_ec_addrs->ds->".$field."->GetValue());");
eval("\$ec_tr_sl_ec_addrs->".$field."->SetValue('');");
}
$rownum++;
And the BeforeShow event on the Grid is:
global $ec_tr_sl_ec_addrs, $rownum;
$rownum=0;
The only thing I don't like about this solution is that have had to move one line of code in the CCS Generated php file for the page
$Tpl->parse("Row", true);
I moved this line so that it is right after the while loop. If I don't move that parse line I see 1 DB record then below that I see 2 side by side then 3 side by side and so on. By moving it to the end of the while it just displays the last ccs "row", which now has all the records in it side by side.
The output is displaying correctly with one column for each record for up to 6 records.
|
|
|
 |
feha
Posts: 712
|
| Posted: 09/03/2005, 4:19 PM |
|
Hi Michael
Here is function i created to read DB and create RSS XML feed:
if(!defined("LANG_CODE"))
{
define("LANG_CODE","en-us");
}
if(!defined("XML_ENCODING"))
{
define("XML_ENCODING","UTF-8");
}
if(!defined("XML_LOGO"))
{
define("XML_LOGO",SITE_URL_ROOT."/News/Feeds/xml_feed.gif");
}
//================ CREATE AN RSS FEED ================/
function create_rss_xml($number_of_pages)
{
$RSS_XML ="";
$RSS_XML .="<?xml version=\"1.0\" encoding=\"".XML_ENCODING."\"?>\n";
$RSS_XML .="<?xml-stylesheet type=\"text/css\" href=\"".SITE_URL_ROOT."/News/css/rss.css\" ?>\n";
$RSS_XML .="<rss version=\"2.0\">\n";
$RSS_XML .="<channel>\n";
$RSS_XML .="<title>".htmlspecialchars(COMPANYNAME)."- Latest News RSS Feed</title>\n";
$RSS_XML .="<link>".SITE_URL."</link>\n";
$RSS_XML .="<description>".htmlspecialchars(COMPANYNAME)."- Homepage, ".$number_of_pages." Latest News RSS 2.0 Feed</description>\n";
$RSS_XML .="<generator>www.vision.to ".APPLICATION_NAME." Version: ".APPLICATION_VERSION."</generator>\n";
$RSS_XML .="<language>".LANG_CODE."</language>\n";
$RSS_XML .="<copyright>Copyright ".COMPANY_START_YEAR." - ".date("Y")." by ".htmlspecialchars(COMPANYNAME)."</copyright>\n";
//$RSS_XML .="<webMaster>".htmlspecialchars(CONTACT_E_MAIL)."</webMaster>\n";
$RSS_XML .="<lastBuildDate>".date("r",CUSTOM_TIME)."</lastBuildDate>\n";
$RSS_XML .="<image>\n";
$RSS_XML .="<title>".htmlspecialchars(COMPANYNAME)."</title>\n";
$RSS_XML .="<url>".XML_LOGO."</url>\n";
$RSS_XML .="<link>".SITE_URL."</link>\n";
$RSS_XML .="<description>".htmlspecialchars(COMPANYNAME)."- Latest News, ".$number_of_pages." Latest News RSS 2.0 Feed</description>\n";
$RSS_XML .="</image>\n";
$DBddd_rss = new clsDBddd();
$SQL = "SELECT * FROM ddd_news WHERE active =1 AND news_feed=1 AND language_ID=1 ORDER BY add_date DESC LIMIT ".$number_of_pages;
$DBddd_rss->query($SQL);
while ($DBddd_rss->next_record()) {
$RSS_XML .= "<item>\n";
$RSS_XML .= "<title>\n";
$RSS_XML .= htmlspecialchars($DBddd_rss->f("news_title"));
$RSS_XML .= "</title>\n";
if($DBddd_rss->f("news_cat_ID") > 0 && $DBddd_rss->f("news_cat_ID")!="")
{
$db = new clsDBddd();
$News_Category="";
$News_Category=CCDLookUp("name", "ddd_news_categories","news_cat_ID=".$db->ToSQL($DBddd_rss->f("news_cat_ID"), ccsInteger)."", $db);
$db->close();
$RSS_XML .="<guid>".SITE_URL_ROOT."/News/index.php?news_cat_ID=".$DBddd_rss->f("news_cat_ID")."&news_id=".$DBddd_rss->f("news_id")."</guid>";
$RSS_XML .="<category>".$News_Category."</category>\n";
}
/*
if($DBddd_rss->f("photo") && file_exists("./Images/thumbs/".$DBddd_rss->f("photo")))
{
$image_attribs = getimagesize("./Images//thumbs/".$DBddd_rss->f("photo"));
$RSS_XML ="<img src=\"".SITE_URL_ROOT."/News/Images/thumbs/".$DBddd_rss->f("photo")."\" width=\"$image_attribs[0]\" height=\"$image_attribs[1]\" alt=\"".$DBddd_rss->f("news_title")."\" /><br />\n";
}
*/
$RSS_XML .= "<description>\n";
$RSS_XML .= "<![CDATA[\n";
$RSS_XML .= $DBddd_rss->f("short_desc");
$RSS_XML .= "\n]]>\n";
$RSS_XML .= "</description>\n";
$RSS_XML .= "<link>".SITE_URL_ROOT."/News/News.php?news_id=".$DBddd_rss->f("news_id")."</link>\n";
if($DBddd_rss->f("news_author"))
{
$RSS_XML .= "<author>".$DBddd_rss->f("news_author")."</author>\n";
}
$RSS_XML .= "<pubDate>".date("r",$DBddd_rss->f("add_date"))."</pubDate>\n";
$RSS_XML .= "</item>\n\n";
}
$DBddd_rss->close();
$RSS_XML .="</channel>\n";
$RSS_XML .="</rss>\n";
//echo $RSS_XML;
$report="";
$filename ="../News/Feeds/RSS/rss.xml";
if(defined("RSS_FEED"))
{
$filename =RSS_FEED;
}
if (!file_exists($filename)) {
touch($filename); // Create blank file rss.xml
}
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'w+')) {
$report="Vision.To CMS:: Cannot open file ($filename), check DIR permissions. (CHMOD 777)";
}
if (!fwrite($handle, $RSS_XML)) {
$report="Vision.To CMS:: Cannot write to file ($filename), check DIR permissions. (CHMOD 777)";
}
$report="Vision.To CMS:: Success, ($filename) has been created, updated ";
fclose($handle);
} else {
$report="Vision.To CMS:: The file $filename is not writable, check DIR permissions. (CHMOD 777)";
}
//create_atom_xml($number_of_pages);
return $report;
}
This may give you an idea ...
_________________
Regards
feha
www.vision.to
feedpixel.com |
 |
 |
|

|
|
|
|