Data in constructor not used on second call of plugin?
Posted: 06 February 2008 01:28 PM
[ Ignore ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
Here is my plugin pseudo-code:
class myPlugin { var foo = '' ; myPlugin () { foo = 'bar' ; } function method1 () { echo $foo ; } function method2 () { echo $foo ; } }
And my template code:
{exp : myPlugin : method1} ... {exp : myPlugin : method2} ... { / exp : myPlugin : method2} ... { / exp : myPlugin : method1}
The method2 call will print out nothing, instead of ‘foo’. Is that intentional?
Posted: 06 February 2008 03:41 PM
[ Ignore ]
[ # 2 ]
Research Assistant
Total Posts: 749
Joined 08-16-2003
Is your sample actually supposed to be:
class myPlugin { var foo = '' ; myPlugin () { $this -> foo = 'bar' ; } function method1 () { echo $this -> foo ; } function method2 () { echo $this -> foo ; } }
Signature
Pst… have you taken a look at Weever yet?
Posted: 06 February 2008 04:49 PM
[ Ignore ]
[ # 3 ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
Yes, keep in mind it was just pseudo code. The issue still exists however.
Posted: 08 February 2008 12:20 PM
[ Ignore ]
[ # 4 ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
Posted: 16 February 2008 11:11 AM
[ Ignore ]
[ # 5 ]
Administrator
Total Posts: 15727
Joined 06-03-2002
Pseudo-code still needs to be accurate, particularly when you are discussing the possibility of something not working. So, what’s different between your actual code and what Mr. Wilson posted?
Signature
Posted: 16 February 2008 11:55 AM
[ Ignore ]
[ # 6 ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
Mr. Wilson’s code is what I have.
Posted: 16 February 2008 11:57 AM
[ Ignore ]
[ # 7 ]
Administrator
Total Posts: 15727
Joined 06-03-2002
And how are you using it? Are you getting any errors? To be sure, the full syntax-error-free version is:
class myPlugin { var $foo = '' ; function myPlugin () { $this -> foo = 'bar' ; } function method1 () { echo $this -> foo ; } function method2 () { echo $this -> foo ; } }
Signature
Posted: 17 February 2008 12:49 AM
[ Ignore ]
[ # 8 ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
This is the offending line:
< a href = "{path=gallery/index}" > Gallery Home </ a > < b >& #8250;</b> {exp:gallery_categoree:parent_category}<a href="{path=gallery/cat}{parent_name}">{parent_name}</a> <b>›</b> {cat_name}{/exp:gallery_categoree:parent_category}
I will attach both the plugin and the template file.
File Attachments
Posted: 18 February 2008 09:41 AM
[ Ignore ]
[ # 9 ]
Administrator
Total Posts: 15727
Joined 06-03-2002
Turn on the template parsing log, Erin. I don’t believe the problem has anything to do with the constructor or class values, but that your nested plugin simply isn’t being called. In your example code, you left out a crucial detail of parse=“inward”.
Signature
Posted: 18 February 2008 09:44 AM
[ Ignore ]
[ # 10 ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
In the only plugin call surrounding my parent_categoree one, I do have this:
{exp : gallery_categoree : categories gallery = "{gallery_name}" parse = "inward" }
Do I need to put it in another place?
Posted: 18 February 2008 09:53 AM
[ Ignore ]
[ # 11 ]
Administrator
Total Posts: 15727
Joined 06-03-2002
Was I right about the plugin not being called?
Signature
Posted: 18 February 2008 09:57 AM
[ Ignore ]
[ # 12 ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
Derek Jones - 18 February 2008 09:53 AM
Was I right about the plugin not being called?
I don’t think you were right, but maybe I am reading the log incorrectly:
( 0.506711 ) Calling Class/ Method : Gallery_categoree / parent_category ( 0.506865 ) -> Class Called : Gallery_categoree ( 0.527692 ) -> Method Called : parent_category ( 0.530037 ) -> Data Returned
Should I attached the entire log?
Posted: 18 February 2008 10:05 AM
[ Ignore ]
[ # 13 ]
Administrator
Total Posts: 15727
Joined 06-03-2002
First, make a reduction template with the most basic example, akin to your original post in this thread. Just those two tags, and the only line of tagdata being the one you are calling the nested plugin. Then please post the template and the parsing log for that reduction test.
Signature
Posted: 18 February 2008 10:20 AM
[ Ignore ]
[ # 14 ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
Template:
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" > < html xmlns = "http://www.w3.org/1999/xhtml" > < head > {embed = "common/html-head" } < style type = 'text/css' media = 'screen' >@ import "{stylesheet=gallery/gallery_css}" ;</ style > </ head > < body > < div id = "wrapper" > {embed = "common/header" } < div id = "content-wrapper" > {exp : gallery_categoree : categories gallery = "{gallery_name}" parse = "inward" } < div id = "content" > < h3 class= "gallery-breadcrumb" > < a href = "{path=gallery/index}" > Gallery Home </ a > < b >& #8250;</b> {exp:gallery_categoree:parent_category}<a href="{path=gallery/cat}{parent_name}">{parent_name}</a> <b>›</b> {cat_name}{/exp:gallery_categoree:parent_category} </ h3 > </ div > <!-- content --> { / exp : gallery_categoree : categories} </ div > <!-- content - wrapper --> </ div > <!-- wrapper --> </ body > </ html >
Debug log attached.
File Attachments
Posted: 18 February 2008 10:32 AM
[ Ignore ]
[ # 15 ]
Administrator
Total Posts: 15727
Joined 06-03-2002
Let’s reduce this further, okay? Eliminate all noise - you don’t need markup, and you don’t need embeds. In this code below, identify which variables are parsed by which tag, and what the unexpected behavior is.
{exp : gallery_categoree : categories gallery = "{gallery_name}" parse = "inward" } {exp : gallery_categoree : parent_category} {parent_name} {cat_name} { / exp : gallery_categoree : parent_category} { / exp : gallery_categoree : categories}
Signature
Posted: 18 February 2008 11:21 AM
[ Ignore ]
[ # 16 ]
Research Assistant
Total Posts: 996
Joined 11-01-2002
Sigh…it turns out I had not one, but TWO bugs in my code; one in my template and one in my plugin.
Sorry to make you waste your time Derek… +1 to the number of beers I owe ya!
Posted: 18 February 2008 11:30 AM
[ Ignore ]
[ # 17 ]
Administrator
Total Posts: 15727
Joined 06-03-2002
Glad I could help you track them down, Erin.
Signature