Page 1 of 1

Problem with PHP 5.2.0 and CMSMS templates

Posted: Wed Oct 31, 2007 12:06 am
by Milhaus
Hi,
recently, I have problem with creating template for Questions (and probably also for other modules). I would like to have expandable/collapsable part of it, which displays answer to question. The user should see answer when he cliks on the question. The code looks like this:

Code: Select all

{starth3ExpandCollapse id="clenstvi_ve_spolku" title="{$entry->question}"}
<ul>
<li>{$entry->answer}</li></ul>
{stopExpandCollapse}
It doesn't work, script ends with this error:
Catchable fatal error: Object of class stdClass could not be converted to string in * on line *
. I found on the internet, that this problem is specific to PHP 5.2.0+ versions, what is my configuration. On PHP site, someone explained it like:
As of (at least) PHP 5.2, you can no longer convert an object to a string unless it has a __toString method. Converting an object without this method now gives the error:

PHP Catchable fatal error:  Object of class could not be converted to string in on line
.

So, please, can you help me implement this method to appropriate object.

Thanks,

Milhaus

Re: Problem with PHP 5.2.0 and CMSMS templates

Posted: Wed Oct 31, 2007 9:52 am
by Milhaus
I tried to add it myself by adding

Code: Select all

function __toString()
	{
		return $entry -> question;
	}
to class Questions definition. However, it still looks the same. Why?

For me, it is also strange, that error occurs on file in templates_c. The exactly line is:

Code: Select all

<?php if ($this->caching && !$this->_cache_including): echo '{nocache:e2cc7d92b8613687b213266593fb8fc9#0}'; endif;echo smarty_cms_function_starth3ExpandCollapse(array('id' => 'clenstvi_ve_spolku','title' => "{".($this->_tpl_vars['entry'])."->question"), $this);if ($this->caching && !$this->_cache_including): echo '{/nocache:e2cc7d92b8613687b213266593fb8fc9#0}'; endif;?>
.

I still hope that someone can solve this...

Milhaus

Re: Problem with PHP 5.2.0 and CMSMS templates

Posted: Wed Oct 31, 2007 8:12 pm
by Milhaus
I understand this issue less and less, since I don't see any object call here now. If I understand correctly, there is array $items, which is used by Smarty foreach in template - each row from this array become $entry array, from which i can use values like $entry -> question.

So where is the object PHP is complaining about?

Thanks for clearing me this situation,

Milhaus

Re: Problem with PHP 5.2.0 and CMSMS templates

Posted: Thu Nov 08, 2007 6:19 pm
by streever
hi there, maybe this is not helpful
but is there a  typo?

{starth3ExpandCollapse id="clenstvi_ve_spolku" title="{$entry->question}"}

that doesn't look right to me.....

shouldn't all that title/etc be WITHIN the startexpandcollapse tag? and why does it have h3 in there?

shouldn't it be:
{startExpandCollapse}
title etc?

Re: Problem with PHP 5.2.0 and CMSMS templates

Posted: Thu Nov 08, 2007 6:23 pm
by calguy1000
Also:

Code: Select all

{starth3ExpandCollapse id="clenstvi_ve_spolku" title="{$entry->question}"}
should be:

Code: Select all

{startExpandCollapse id="clenstvi_ve_spolku" title="$entry->question"}
You can't nest the { brackets in smarty calls.  and I changed the starth3ExpandCollapse to startExpandCollapse just incase it was a typo

Re: Problem with PHP 5.2.0 and CMSMS templates

Posted: Sun Nov 11, 2007 12:15 am
by michelG
Like Milhaus, I attempted to generate the same interface behavior for the Questions' module and got the same problem under a server running PHP 5.2.3.

Calguy, the additonal brackets are not the issue. It still doesn't work.

Milhaus, as I am not a PHP/Smarty guru I solved my problem by replacing the startExpandCollapse tag with a simple javascript. Code is below.

(Edited--Moved example to separate post:)

http://forum.cmsmadesimple.org/index.php/topic,16892.0.html


Still, I would like to know what is the solution to the issue expressed by Milhaus.

Michel

Re: Problem with PHP 5.2.0 and CMSMS templates

Posted: Mon Nov 12, 2007 5:36 pm
by streever
hello michel,
did you also post his line of startexpandcollapse? because his has a definite type in it...

just wondering, please reply :)

Re: Problem with PHP 5.2.0 and CMSMS templates

Posted: Tue Nov 13, 2007 3:43 am
by michelG
Yes Streever. Even with the right spelling for startExpandCollapse the problem is the same. /Michel

Re: Problem with PHP 5.2.0 and CMSMS templates

Posted: Tue Nov 13, 2007 3:15 pm
by streever
hey michel,

sorry this is still being a problem!

If it's the proper spelling, it must be that their is an issue somewhere with that string: i'd submit a bug report & continue to use your javascript solution.

It seems strange though because I think the plugin is doing almost the same thing.