A place for users and developers of the Xataface to discuss and receive support.
by kokoro » Fri Mar 13, 2009 1:47 am
I am working on setting up multiple tables in a database with one table functioning as the "main" table and data in all the other tables related to the "main" table. I'd like to set up relationships with the main table as the target table and have them appear in Xataface the way they do in the Credit Union example found on the "Sample Applications" page.
Here is a link to a single record that I'm trying to mimic
http://www.credituniondb.com/view/Quinc ... 65426.html
Of course I don't need the advertisements found on the left side of the screen
I am trying to figure out how to hone the relationship settings so that I can have multiple relationships show up in a vertical list the way they do in the example I've provided here. In the example there is:
Details
Address
Loans Information
with a list of fields under each.
Right now when I set up a relationship I get it listed on the bottom left of the current record as a link with an RSS link, a search box, an XML export link etc. I'd like to remove all of this and just have the related information show up the way it does in the Credit Union example.
Have I missed a tutorial somewhere or a very informative post somewhere here on the forums? If so, I apologize for asking for help with something that is already documented. If not, any help will be appreciated.
Jason
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
by shannah » Fri Mar 13, 2009 8:04 am
The example that you are referring to actually doesn't use relationships at all. All of the fields on that page are part of a single table. They are just partitioned into field groups.
You could mimic this with relationships, however by adding a custom section to your view tab for the main table.
http://xataface.com/wiki/How_to_Add_Cus ... o_View_Tab
In your custom section you could just loop through the related values that you have:
- Code: Select all
echo '<table>'; foreach ( $record->getRelatedRecordObjects('foo') as $rrec){ echo '<tr><th>'.$rrec->val('name').'</th><td>'.$rrec->val('value').'</td></tr>'; }
This example assumes that you have a relationship called 'foo' to a table with two columns: name and value.
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by kokoro » Fri Mar 13, 2009 2:05 pm
Steve,
Thanks, I'll try setting up the custom view tab this way. I really appreciate the help you provide here in the forums.
Do you have a business entity that provides Xataface development services for a fee? I am working on a development project that I have obtained grant funding for at my university and may need to ask for help beyond the services I am already contracting out for some Moodle development.
Jason
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
by shannah » Fri Mar 13, 2009 2:13 pm
Hi Jason,
No problem. Glad to see you getting going with the framework. I do offer consulting through Web Lite Solutions ( http://solutions.weblite.ca) or just email me at steve@weblite.ca for inquiries or quotes.
Best regards
Steve
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by kokoro » Wed Mar 18, 2009 3:22 pm
Steve,
Thanks for the tip on how to add the relationship to the tab here but....
I don't know what I'm doing wrong but I am not able to get a custom section to appear in the view tab. I've followed the instructions in the tutorial
http://xataface.com/wiki/How_to_Add_Cus ... o_View_Tab
and even tried simply copying and pasting the code samples into the delegate class php file located in my table directory but when I reload the page I don't see any changes...?
Jason
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
by kokoro » Wed Mar 18, 2009 3:37 pm
Steve,
Sorry, it seems that I'm figuring out my issues immediately after posting here on the forums again
I had a very small error in the code in my delegate class and thus the code added to add a custom section to the view tab was getting ignored. Fixed now and I managed to get the tab customization working.
Sorry for the false alarm.
Now that I've got it working, I'm wondering how exactly to use the code snippet that you provided.
Right now I have:
- Code: Select all
class tables_dataface_nuelpstudents {
function section__slep(&$record){ return array( 'content' => 'Hello World!!!', 'class' => 'main', 'label' => 'SLEP Score', 'order' => 10 ); } } ?>
and I want to add the piece you provided but I'm not certain where it should be inserted. Does it need to be in the 'content' section?
Jason
P.S. Oops, it looks like I was editing this post while you were responding.
Last edited by kokoro on Wed Mar 18, 2009 3:50 pm, edited 3 times in total.
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
by shannah » Wed Mar 18, 2009 3:46 pm
No need to apologize. Documenting your trials in the forum like this could be helpful to current and future users of Xataface who may run across the same difficulties. For new users, even finding out that other have had the same problem and solved it can be reassuring.
-Steve
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by kokoro » Wed Mar 18, 2009 3:52 pm
Steve,
Thanks for your friendly support. It's really nice for a beginner like me to receive the type of guidance you provide.
I was in the midst of editing my last post as you were responding so it may seem a bit disjointed but...
Can you provide a quick pointer on where I need to add the example you provided? (The echo statement to get my relationship fields to appear in a new section)
Jason
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
by kokoro » Wed Mar 18, 2009 4:03 pm
Steve,
Here is what I have so far (I'm sure it will make you and other's who are php-literate chuckle).
- Code: Select all
class tables_dataface_nuelpstudents {
function section__slep(&$record){ return array( 'content' => echo '<table>'; foreach ( $record->getRelatedRecordObjects('Extra Information') as $rrec){ echo '<tr><th>'.$rrec->val('s1').'</th><td>'.$rrec->val('s2').'</td></tr>'; }, 'class' => 'main', 'label' => 'SLEP Score', 'order' => 10 ); } }
It is obviously not working though.
Plugging the echo '<table>' line in for the content wasn't the right idea I guess.
Jason
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
by shannah » Wed Mar 18, 2009 4:25 pm
You're having a syntax issue. You are defining an array only partially, before ending the statement.
First build the content and put it into a variable, then plug that variable into the 'content' key of the return array.
E.g.
- Code: Select all
function section__slep(&$record){ $content = '<table>'; foreach ( $record->getRelatedRecordObjects('Extra Information') as $rrec){ $content .= '<tr><th>'.$rrec->val('s1').'</th> <td>'.$rrec->val('s2').'</td></tr>'; } return array( 'content'=>$content , 'class' => 'main', 'label' => 'SLEP Score', 'order' => 10 ); }
for example.
Another cleaner way to handle the output would be to use the df_display() function and use a templates... but one step at a time.
-Steve
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by kokoro » Wed Mar 18, 2009 5:08 pm
Steve,
Thanks, your patience is amazing
Here is what I have so far
- Code: Select all
class tables_dataface_nuelpstudents {
function section__slep(&$record){ $content = '<table>'; foreach ( $record->getRelatedRecordObjects('Extra Information') as $rrec){ $content .= '<tr><th>'.$rrec->val('S1').'</th> <td>'.$rrec->val('S2').'</td></tr>'; } return array( 'content' => $content , 'class' => 'main', 'label' => 'SLEP Score', 'order' => 10 ); } }
It wasn't working and then I realized that the column headings for the two values I'm trying to return were uppercase instead of lower and thought that maybe case sensitivity was an issue so I changed them to the correct uppercase "S1" & "S2" but unfortunately that wasn't the issue.
The worst thing is that I'm using a MAMP sever on my laptop for development and I can't figure out how to find the error logs....so all I know is that I'm getting a white screen.
Thanks again for all your help. Hopefully some day I'll be in a position to help others....some day.
Jason
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
by shannah » Thu Mar 19, 2009 9:25 am
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by kokoro » Thu Mar 19, 2009 5:14 pm
Steve,
Thanks, I have error reporting on now and am getting the following error:
Fatal error: Call to undefined method PEAR_Error::getOrderColumn() in /Applications/MAMP/htdocs/moodle19/myapp/xataface/Dataface/Record.php on line 779
With the code that I entered in the previous post.
Jason
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
by shannah » Thu Mar 19, 2009 5:55 pm
This is likely caused by the "space" in your relationship name (Extra Information). Try renaming the relationship to something like "extra_information". Use the action:label directive in the relationships.ini file to set the label to your desired label - and update your code accordingly to use the new relationship name.
-
shannah
-
- Posts: 4457
- Joined: Wed Dec 31, 1969 5:00 pm
by kokoro » Thu Mar 19, 2009 8:00 pm
Steve,
Thanks. I am not usually this absent minded but it seems that I made another silly mistake.
I revisited the relationships file in the table I am working with and while looking at it, opened the delegate class php file in the same directory and to my shock found that I had listed the wrong name for the relationship  The relationship that I had "Extra Information" was actually from a different table. When I changed it to the correct relationship things moved forward. I got an error related to the title column of the table I was trying to retrieve information from (SI not S1) and once that was corrected, everything works!
I am sorry to have taken your time for a simple miss on my part.
Now,  I am wondering if there is a way to make the "Sub section" that appears on the left side of the record (includes the RSS, search, link to related table etc.) disappear so that the customized section I've just added is the only information (aside from the tab that appears at the top of the record) displayed when using the view tab.
Jason
-
kokoro
-
- Posts: 39
- Joined: Fri Feb 06, 2009 6:17 am
Return to Xataface Users
Who is online
Users browsing this forum: No registered users and 15 guests
|