Problem with PHP 5.2.0 and CMSMS templates

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
Milhaus

Problem with PHP 5.2.0 and CMSMS templates

Post 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
Last edited by Milhaus on Wed Oct 31, 2007 8:14 pm, edited 1 time in total.
Milhaus

Re: Problem with PHP 5.2.0 and CMSMS templates

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

Re: Problem with PHP 5.2.0 and CMSMS templates

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

Re: Problem with PHP 5.2.0 and CMSMS templates

Post 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?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Problem with PHP 5.2.0 and CMSMS templates

Post 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
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.
michelG
Forum Members
Forum Members
Posts: 43
Joined: Tue Jul 17, 2007 1:25 pm
Location: Rochester, NY

Re: Problem with PHP 5.2.0 and CMSMS templates

Post 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
Last edited by michelG on Tue Nov 13, 2007 4:01 am, edited 1 time in total.
streever

Re: Problem with PHP 5.2.0 and CMSMS templates

Post by streever »

hello michel,
did you also post his line of startexpandcollapse? because his has a definite type in it...

just wondering, please reply :)
michelG
Forum Members
Forum Members
Posts: 43
Joined: Tue Jul 17, 2007 1:25 pm
Location: Rochester, NY

Re: Problem with PHP 5.2.0 and CMSMS templates

Post by michelG »

Yes Streever. Even with the right spelling for startExpandCollapse the problem is the same. /Michel
streever

Re: Problem with PHP 5.2.0 and CMSMS templates

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

Return to “Developers Discussion”