using CreateInputSelectList

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
rlparker25
Forum Members
Forum Members
Posts: 57
Joined: Thu Jan 17, 2008 3:58 pm

using CreateInputSelectList

Post by rlparker25 »

I am trying to create a module where you can create pieces of content and then select from a list which pages you want it to appear on.

I have everything working except the select list. This is the code I am using

Code: Select all

//create array of all the active pages
$myquery = "SELECT * FROM cms_content WHERE active=1";
$myresult = $db->Execute( $myquery );

$pagearray = array();
while ($myresult && $myrow = $myresult->FetchRow())
{
 	$pagearray[$myrow['content_name']] =  $myrow['content_id'];
}
 
$selpages = explode(',',$row['pages']);// this creates an array of page ids that are stored in the database in a field called pages
$selpagearray = array();
for ($i=0; $i <sizeof($selpages); $i++) 
{
	$query2 = 'SELECT content_name FROM cms_content WHERE content_id = '.$selpages[$i];
                $row2 = $db->GetRow($query2);
	$selpagearray[$row2['content_name']] = $selpages[$i]; // build array of pages that should be selected
}
 
$this->$smarty->assign('inputpages', $this->CreateInputSelectList($id,'pages[]',$pagearray,$selpagearray)); 
$this->smarty->assign('pagestext', $this->Lang('pages')); 
When I dump the two arrays I create this is what I get

array(5) { ["Home"]=> string(2) "15" ["test form"]=> string(2) "16" ["podcast"]=> string(2) "17" ["events"]=> string(2) "18" ["gallery"]=> string(2) "23" }

array(2) { ["Home"]=> string(2) "15" ["podcast"]=> string(2) "17" }

and this is the error I am getting

Catchable fatal error: Object of class Smarty_CMS could not be converted to string in /home/bible/SQ32P4N3/htdocs/modules/YMABII/action.editContent.php

it doesn't seem to matter what array I put into the function I still get the same error. Could someone please tell me where I am going wrong or give me a working example?

Thank you

Rachael
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: using CreateInputSelectList

Post by calguy1000 »

uhm... simple mistake:

Code: Select all

$this->$smarty
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
rlparker25
Forum Members
Forum Members
Posts: 57
Joined: Thu Jan 17, 2008 3:58 pm

Re: using CreateInputSelectList [solved]

Post by rlparker25 »

d'oh!

thank you, you're a star!!!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: using CreateInputSelectList

Post by calguy1000 »

BTW.

I wouldn't rely on $this->smarty at all.
one of these days the smarty member is gonna be removed from the module.... it's redundant

$smarty is available in all module actions
and if it's not you can always do a:

Code: Select all

global $gCms;
$smarty =& $gCms->GetSmarty();
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “Developers Discussion”