Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Customising the CMS

Passing a variable to a function through the URL


18 Posts   5686 Views


12 August 2009 at 12:50am Community Member, 26 Posts

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: [url][/url].

It's this line that gives the error:

// template engine needs that to render
      return array();

Maybe I should just give up now hehe. I'm in way over my head with this code!


12 August 2009 at 1:00am Community Member, 901 Posts

That line looks just fine. Can you post your page-code to and post the link here? (Remove sensible information like db-connection params first)


12 August 2009 at 1:06am Community Member, 26 Posts

Sure here it is: [url][/url]

Thanks so much for your patience.


12 August 2009 at 1:26am Community Member, 901 Posts

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 :)


12 August 2009 at 3:46am Community Member, 26 Posts

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 error

The 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

<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>
                  <% control MemberData %>
                        <tr class="rostertr">
                           <td class="rostername">$Name</td>
                           <td class="rosterlvl">$Level</td>
                           <td class="rosterrank">$Class</td>
                  <% end_control %>
   <% if Menu(2) %>
   <% end_if %>

Thanks again banal. I owe you big time!


12 August 2009 at 4:22am (Last edited: 12 August 2009 4:25am), Community Member, 901 Posts

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:

Let'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


Edit: found another error in the code. Try the above (, it should be ok now


12 August 2009 at 6:29am Community Member, 26 Posts

It works now! You're officially my hero :)

Have a look at: [url][/url]

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.


12 August 2009 at 7:27am Community Member, 901 Posts

Well, yes. I thought you were just interested in that single row...
This code should return all results: