write data to database through a theme

write data to database through a theme

by Constantinos Delistavrou -
Number of replies: 7
is it possible to use a moodle's database table for saving theme oriented data?

please reply!
Average of ratings: -
In reply to Constantinos Delistavrou

Re: write data to database through a theme

by Dave Perry -
Picture of Testers
Depends what theme related data you're wanting to store. We personally use a homebrew script to store which theme the user wants to see (one is a standard, one is custom) that doesn't touch moodle's database library (easier) - same database though, we just setup a new table. Never tried using inbuilt moodle data libraries, although the reasons for using them seem fair.


Dave
In reply to Dave Perry

Απάντηση: Re: write data to database through a theme

by Constantinos Delistavrou -
First of all, thank you Dan & Dave for (both) the responses.

I'm trying to use ajax to make a more interactive. I managed using YUI to make interface's objects (blocks) freely drag and dropable around the webtop.

I try unsuccessfully to create (through XMLDB and moodle's DDLlib) a script to create a table if it doesn't exist. The table will hold each item's X, Y coords and the user (each user except visitors, not just the admin) will have the opportunity to press a button to save his items favourite positions.

I think this is possible because every user has at least DML read/write access to a moodle DB table. Chameleon does something like this but with css attribs (colors, fonts, etc). It saves changes by altering the css files and this is available only to admins. I like to give webtop freedom to all users.

I try hard to include ddllib etc to make valid moodle code but with no result. I altered some tutorial scripts to fit to my needs but with no result.

I feel that the problem might be the invokation of ddllib from theme dir and not mod dir? I don't really know. I'm confused and quite dissapointed.

Please give any kind of tip. My next attempt will be to manipulate DB throuph plain SQL (really, is this ok with contributing code? I would love to be XMLDB compatible but I sweat like climbing a mountain - this DOES NOT work for me, MERCY).

Help is allways welcome,
Costas

In reply to Dave Perry

Απάντηση: Re: write data to database through a theme

by Constantinos Delistavrou -
Dear Dave,

Do you have any code sample on how to connect to a table without moodle code (as far as I understood that you do on your implementation) but with plain php?

I try to connect to a db table using php with no success.

Thanx in advance,
Costas
In reply to Constantinos Delistavrou

Re: Απάντηση: Re: write data to database through a theme

by Dave Perry -
Picture of Testers
Sample code:

<?php
//open up connection to your mysql database server which has the moodle db
$db = mysql_connect("serverHostnameOrIP","username","password");
//use this connection to connect to the moodle database
$db = mysql_select_db("moodle",$db);
?>

HTH

Dave
In reply to Constantinos Delistavrou

Re: write data to database through a theme

by Dan Humpherson -
What kind of information would you want to save to the database regarding the theme?
In reply to Dan Humpherson

Απάντηση: Re: write data to database through a theme

by Constantinos Delistavrou -
First of all, thank you Dan & Dave for (both) the responses.

I'm trying to use ajax to make a more interactive. I managed using YUI to make interface's objects (blocks) freely drag and dropable around the webtop.

I try unsuccessfully to create (through XMLDB and moodle's DDLlib) a script to create a table if it doesn't exist. The table will hold each item's X, Y coords and the user (each user except visitors, not just the admin) will have the opportunity to press a button to save his items favourite positions.

I think this is possible because every user has at least DML read/write access to a moodle DB table. Chameleon does something like this but with css attribs (colors, fonts, etc). It saves changes by altering the css files and this is available only to admins. I like to give webtop freedom to all users.

I try hard to include ddllib etc to make valid moodle code but with no result. I altered some tutorial scripts to fit to my needs but with no result.

I feel that the problem might be the invokation of ddllib from theme dir and not mod dir? I don't really know. I'm confused and quite dissapointed.

Please give any kind of tip. My next attempt will be to manipulate DB throuph plain SQL (really, is this ok with contributing code? I would love to be XMLDB compatible but I sweat like climbing a mountain - this DOES NOT work for me, MERCY).

Help is allways welcome,
Costas