Enumerate / List / Show all pages as one long page

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Post Reply
martinbirchdk
New Member
New Member
Posts: 2
Joined: Sat Apr 11, 2009 8:23 pm

Enumerate / List / Show all pages as one long page

Post 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
martinbirchdk
New Member
New Member
Posts: 2
Joined: Sat Apr 11, 2009 8:23 pm

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

Post 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
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

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

Post by jmcgin51 »

martinbirchdk wrote: BTW... what is the best way to donate?
http://www.cmsmadesimple.org/about-link/donations
NaN

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

Post 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
Post Reply

Return to “Developers Discussion”