Page 1 of 1

Enumerate / List / Show all pages as one long page

Posted: Sat Apr 11, 2009 8:44 pm
by martinbirchdk
Hello

I have just switched to CMSMS and need to know how I can access MySQL from within CMSMS. In this specific case I need to enumerate / list / show all active pages as one long pages. Is this possible? Preferable would be some sort of solution, where I don't need to specifiy DB name/username/password, but just use the already authenticated DB connection. Plan B would be a from-scratch solution... connection to localhost, given it username/pasword etc. etc.

Thanks in advance.

Best regards
Martin

Re: Enumerate / List / Show all pages as one long page

Posted: Sun Apr 12, 2009 10:02 am
by martinbirchdk
After searching the forum, looking into different modules and some trail and error programming, I think I got the right setup. The below pulls out all content from pages that are shown in the menu:

1) I create a new UDT (user defined tag): testing
2) I insert the following code

Code: Select all

global $gCms;
$db = &$gCms->db;
$myquery = "SELECT cms_content_props.content FROM cms_content_props JOIN cms_content ON cms_content.content_id = cms_content_props.content_id WHERE (cms_content.show_in_menu=1) AND (cms_content_props.prop_name='content_en')";
$myresult = $db->Execute( $myquery );
if ( !$myresult )
{
	echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
while ($myresult && $myrow = $myresult->FetchRow())
{
	echo $myrow['content'];
}
3) In my page template I place {testing} in the right place

Question to the specialists... do I need to open / close my mysql connection if I use the above? Any things I could do better / optimize?

P.S. I have been testing looots of CMS solutions (MySQL/PHP) and CMS Made Simple just beats them all. Especially the template/CSS/menu/UDT construction rocks!! We will for sure donate money everytime we use it for customer projects. BTW... what is the best way to donate?

Best regards
Martin

Re: Enumerate / List / Show all pages as one long page

Posted: Sat Apr 18, 2009 3:25 pm
by jmcgin51
martinbirchdk wrote: BTW... what is the best way to donate?
http://www.cmsmadesimple.org/about-link/donations

Re: Enumerate / List / Show all pages as one long page

Posted: Sat Apr 18, 2009 4:06 pm
by NaN
martinbirchdk wrote: show all active pages as one long pages. Is this possible?
have you ever heard of the contentdump plugin? ;)

http://dev.cmsmadesimple.org/projects/contentdump