5093 Posts in 1516 Topics by 1113 members
| Go to End | Next > | |
| Author | Topic: | 3206 Views |
-
Re: Passing a variable to a function through the URL

12 August 2009 at 12:50am
Sorry didn't spot that.
Fixed that and removed the var_dump statements but it gives me the same error.
To be honest I'm not really sure what I'm doing so I'm just trying to put your example together with the "Transforming a result to DataObjectSet" here: http://doc.silverstripe.com/doku.php?id=sqlquery.
It's this line that gives the error:
// template engine needs that to render RosterPage_alts.ss
return array();Maybe I should just give up now hehe. I'm in way over my head with this code!
-
Re: Passing a variable to a function through the URL

12 August 2009 at 1:00am
That line looks just fine. Can you post your page-code to http://pastebin.com/ and post the link here? (Remove sensible information like db-connection params first)
-
Re: Passing a variable to a function through the URL

12 August 2009 at 1:06am
Sure here it is: http://pastebin.com/f4bfa766f
Thanks so much for your patience.
-
Re: Passing a variable to a function through the URL

12 August 2009 at 1:26am
Hey Brig
There was just a semicolon (;) missing
$this->memberData = $PlayerAlt; // assign the DataObjectSet to $this->memberData
I also moved the DB config to a member variable, since you use that in other functions too.
You also had a function to get each class individually... that's overkill. I rewrote the Members function, so that it does all that in one.
In the template you can now use: $Members(Paladins) instead of $Paladins. To output all Members, just use $Members as before.Here's to complete class, hopefully there's no error in there
http://pastebin.com/m65bc1dbd -
Re: Passing a variable to a function through the URL

12 August 2009 at 3:46am
banal can't thank you enough! I think this works!
The functions you cleaned up for me works perfectly, must neater than before
When I try to use the alts function with the URL parameter I get:
Website Error
There has been an errorThe website server has not been able to respond to your request.
Just as if the function isn't loading.
What do you think could be wrong? Hopefully it's just something simple.
Here's my Roster_alts.ss
<div class="typography-site">
<% if Menu(2) %>
<% include SideBar %>
<div id="Content">
<% end_if %>
<% if Level(2) %>
<% include BreadCrumbs %>
<% end_if %>
<div class="rosterwrapper">
<!-- Alts -->
<table class="rostertable" cellpadding="0" cellspacing="0">
<tr class="rostertr">
<td class="rostertdleft" colspan="4"><strong>Alts</strong></td>
</tr>
<% control MemberData %>
<tr class="rostertr">
<td class="rostername">$Name</td>
<td class="rosterlvl">$Level</td>
<td class="rosterrank">$Class</td>
</tr>
<% end_control %>
</table>
</div>
<% if Menu(2) %>
</div>
<% end_if %>
</div>Thanks again banal. I owe you big time!
-
Re: Passing a variable to a function through the URL

12 August 2009 at 4:22am Last edited: 12 August 2009 4:25am
That template looks fine to me.
I guess there's a problem with the singleton('roster') statement. This will probably try to instantiate a class named "roster" which doesn't exist.. or doesn't have the required datafields.I modified the code slightly, so that the first result set is simply returned as DataObject:
http://pastebin.com/m709e0480Let's hope this works, otherwise there's probably something wrong with the DB connection, but for other things it seems to work... If my new code doesn't work, you could switch on debugging to get a more detailed error message. To do so, add the following to mysite/_config.php
Director::set_environment_type('dev');
Edit: found another error in the code. Try the above (http://pastebin.com/m709e0480), it should be ok now
-
Re: Passing a variable to a function through the URL

12 August 2009 at 6:29am
It works now! You're officially my hero
Have a look at: http://nda.johannesengstrom.com/guild-roster/alts/Bexie
Just one thing missing. Currently it only selects one row in the database and displays it on the page so if there is more than one row it just takes the first one in the table.
Like before I had
$result = new DataObjectSet();
foreach($query as $row) {
$result->push(new ArrayData($row));I assume I need to fit foreach into the new SQLQuery as well?
I haven't found an example for it yet but I imagine it's probably not a big thing.
-
Re: Passing a variable to a function through the URL

12 August 2009 at 7:27am
Well, yes. I thought you were just interested in that single row...
This code should return all results: http://pastebin.com/m25c6a1ce
| 3206 Views | ||
| Go to Top | Next > |


